pubsub

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a middleman between the websocket connection and the hub.

func NewClient

func NewClient(hub Pubsuber, conn *websocket.Conn, user *model.User) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) IsSubscribed added in v0.4.0

func (c *Client) IsSubscribed(topic string) bool

func (*Client) Start added in v0.4.0

func (c *Client) Start() error

func (*Client) Subscribe added in v0.4.0

func (c *Client) Subscribe(topic string)

func (*Client) User added in v0.4.0

func (c *Client) User() *model.User

type Hub

type Hub struct {
	TokenSecret []byte
	TokenExpire time.Duration
	TokenIssuer string
	Users       *store.Users
	// contains filtered or unexported fields
}

func NewHub

func NewHub(tokenSecret []byte, tokenExpire time.Duration, tokenIssuer string, users *store.Users) *Hub

func (*Hub) Broadcast added in v0.4.0

func (h *Hub) Broadcast(msg Message) error

func (*Hub) Register added in v0.4.0

func (h *Hub) Register(c *Client) error

func (*Hub) ServeWs added in v0.4.0

func (h *Hub) ServeWs() http.Handler

func (*Hub) Start added in v0.4.0

func (h *Hub) Start() error

func (*Hub) Unregister added in v0.4.0

func (h *Hub) Unregister(c *Client) error

type Message

type Message interface {
	Topic() string
	Data() interface{}
	ShouldSendTo(*Client) bool
}

type Pubsuber added in v0.4.0

type Pubsuber interface {
	Start() error
	Register(*Client) error
	Unregister(*Client) error
	Broadcast(Message) error
	ServeWs() http.Handler
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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