client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BayeuxHandler

type BayeuxHandler interface {
	HandleMessage(message []byte) error
	ReaderDisconnect()
}

A BayeuxHandler is responsible for parsing bayeux messages

type Client

type Client struct {
	Host        string
	MessageChan chan Message // Messages recv'd by the client will be sent to this message channel
	// contains filtered or unexported fields
}

A Client is a connection and a set of subscriptions TODO: remap MessageChan to a set of subscription message channels one per active subscription

func NewClient

func NewClient(host string) *Client

NewClient creates a new client for a given host and returns a pointer to it

func (*Client) Disconnect

func (f *Client) Disconnect()

Disconnect disconnects from the Bayeux server

func (*Client) HandleMessage

func (f *Client) HandleMessage(message []byte) error

HandleMessage parses and interprets a bayeux message response

func (*Client) Publish

func (f *Client) Publish(channel string, data map[string]interface{}) error

Publish sends a message to the server to publish a message

func (*Client) ReaderDisconnect

func (f *Client) ReaderDisconnect()

ReaderDisconnect is called by the connection handler if the reader connection is dropped by the loss of a server connection

func (*Client) SetKeepAliveIntervalSeconds

func (f *Client) SetKeepAliveIntervalSeconds(secs int)

SetKeepAliveIntervalSeconds sets the keep alive interval for the client

func (*Client) Start

func (f *Client) Start(ready chan bool) error

Start spins up the main client loop

func (*Client) Subscribe

func (f *Client) Subscribe(channel string) error

Subscribe sends a message to the server to subscribe to the given channel

func (*Client) Unsubscribe

func (f *Client) Unsubscribe(channel string) error

Unsubscribe sends a message to the server to unsubscribe from the given channel

func (*Client) Write

func (f *Client) Write(msg string) error

Write sends a message to the bayeux server over the websocket connection

type Connection

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

A Connection is a websocket connnection and state

func NewConnection

func NewConnection(ws *websocket.Conn) *Connection

NewConnection instantiates and returns a new Connection object

func (*Connection) Connected

func (c *Connection) Connected() bool

Connected returns a bool indicating the connection state of both the reader and writer on the connection

type Message

type Message struct {
	Channel string
	Data    map[string]interface{}
	Ext     map[string]interface{}
}

A Message is a piece of data sent to a channel from the bayeux server

type Subscription

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

A Subscription is represents a subscription to a channel by the client Each sub has...

  • a messageChan which is recieve any messages sent to it

Jump to

Keyboard shortcuts

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