wspool

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidWsMessage is the error of an invalid websocket message
	ErrInvalidWsMessage = mustPrepareMessage("invalid websocket message")
	// ErrInternalError describes a server-side error
	ErrInternalError          = mustPrepareMessage("internal server error")
	ErrTooManyInvalidMessages = mustPrepareMessage("too many invalid messages")
)
View Source
var ErrInvalidMessageType = errors.New("invalid message type")

Functions

This section is empty.

Types

type Client

type Client struct {
	Hub      *Hub
	Conn     *websocket.Conn
	Received chan ClientRequest
	Send     chan *websocket.PreparedMessage
	Closed   chan struct{}

	InvalidCount int
	// contains filtered or unexported fields
}

Client is a intermediate module to connect user-side websocket client with hub

func NewClient

func NewClient(hub *Hub, conn *websocket.Conn) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) Read

func (c *Client) Read()

Read block-reads from the underlying websocket.Conn. It also parses skeleton for further unmarshalling

func (*Client) Write

func (c *Client) Write()

type ClientRequest

type ClientRequest struct {
	Skeleton *messages.Skeleton
	Body     []byte
}

ClientRequest is the skeleton-unmarshalled client side request

type Hub

type Hub struct {
	Clients    map[*Client]bool
	Register   chan *Client
	Unregister chan *Client
	// contains filtered or unexported fields
}

Hub consists of current active clients

func NewHub

func NewHub() *Hub

NewHub creates a new Hub

func (*Hub) Run

func (h *Hub) Run()

Run listens for channel update on client connect and disconnects and reflects them on the internal Clients property

Jump to

Keyboard shortcuts

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