pusher

package module
v0.0.0-...-cf7f450 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: MIT Imports: 7 Imported by: 0

README

go-pusher

A golang Pusher client ()

Installation

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

Usage

See client.go in examples folder

Todo

  • Pusher Server

Donate

Donation QR

1HgpsmxV52eAjDcoNpVGpYEhGfgN7mM1JB

Documentation

Index

Constants

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

ErrEvent error on event

Variables

This section is empty.

Functions

func NewWSS

func NewWSS(appKey, host, scheme, client, protocol, version string) (ws *websocket.Conn, err error)

NewWSS return a websocket connexion

Types

type Client

type Client struct {
	Events chan *Event
	Stop   chan bool
	Errors chan error
	// 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, client, protocol, version string) (*Client, error)

NewCustomClient return a custom client

func (*Client) Bind

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

Bind an event

func (*Client) Close

func (c *Client) Close() error

Close the underlying Pusher connection (websocket)

func (*Client) Stopped

func (c *Client) Stopped() bool

Stopped checks, in a non-blocking way, if client has been closed.

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"`
	Channel string `json:"channel"`
}

Event is a pusher event

type EventError

type EventError struct {
	Event string `json:"event"`
	Data  struct {
		Message string `json:"message"`
		Code    int    `json:"code"`
	} `json:"data"`
}

EventError contains a structured error in its Data field. It implements error.

func (EventError) Error

func (ewe EventError) Error() string

type EventStub

type EventStub struct {
	Event string `json:"event"`
}

EventStub contains just the "type" of event. Knowing the type, we can then unmarshal again, into appropriate type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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