bayeux

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Adapted from https://github.com/andreas/go-bayeux-client

Index

Constants

View Source
const (
	VERSION         = "1.0"
	MINIMUM_VERSION = "1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client allows connecting to a Bayeux server and subscribing to channels.

func NewClient

func NewClient(force *Force) *Client

NewClient initialises a new Bayeux client. By default `http.DefaultClient` is used for HTTP connections.

func (*Client) Close

func (c *Client) Close() error

Close notifies the Bayeux server of the intent to disconnect and terminates the background polling loop.

func (*Client) Connect

func (c *Client) Connect() error

Connect performs a handshake with the server and will repeatedly initiate a long-polling connection until `Close` is called on the client.

func (*Client) Subscribe

func (c *Client) Subscribe(pattern string, out chan<- *Message) error

Subscribe is like `SubscribeExt` with a blank `ext` part.

func (*Client) SubscribeExt

func (c *Client) SubscribeExt(pattern string, out chan<- *Message, ext interface{}) error

SubscribeExt creates a new subscription on the Bayeux server. Messages for the subscription will be delivered on the given channel `out`. If the client has not performed a handshake already, it will do so first.

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(pattern string) error

type Message

type Message struct {
	Channel   string          `json:"channel"`
	Data      json.RawMessage `json:"data,omitempty"`
	Id        string          `json:"id,omitempty"`
	ClientId  string          `json:"clientId,omitempty"`
	Extension interface{}     `json:"ext,omitempty"`
}

Message is the type delivered to subscribers.

Jump to

Keyboard shortcuts

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