pusher

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2020 License: MIT Imports: 7 Imported by: 0

README

go-pusher

A golang Pusher client ()

This is a fork by avdva, which brings some improvements with thread-safety and graceful close.

Installation

$  go get github.com/avdva/go-pusher

Usage

See client.go in examples folder

Todo

  • Pusher Server

Documentation

Index

Constants

View Source
const (
	ME                      = "Go-Pusher-avd"
	VERSION                 = "0.2"
	PROTOCOL_VERSION        = "7"
	EVENT_CHANNEL_BUFF_SIZE = 1000 // events channel buffer size
	HEARTBEAT_RATE          = 30   // time in second between 2 beats
)

ME and other consts describe the library.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a pusher client.

func NewClient

func NewClient(appKey string) (*Client, error)

NewClient initialize & return a Pusher client

func NewCustomClient

func NewCustomClient(appKey, host, scheme string) (*Client, error)

NewCustomClient initialize & return a Pusher client for given host and sheme.

func (*Client) Bind

func (c *Client) Bind(evt string) (dataChannel chan *Event, err error)

Bind an event. Bind returns a channel, where events will be sent. The channel will be closed, if a websocket read error occurs.

func (*Client) Close

func (c *Client) Close()

Close closes websocket conn and unbinds all events.

func (*Client) Subscribe

func (c *Client) Subscribe(channel string) (err error)

Subscribe to a channel

func (*Client) Unbind

func (c *Client) Unbind(evt string)

Unbind a event

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(channel string) (err error)

Unsubscribe from a channel

type Event

type Event struct {
	Event string `json:"event"`
	Data  string `json:"data"`
}

Event is a pusher event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL