clients

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const WriteWait = time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforeCloseCallback

type BeforeCloseCallback func(id string, conn *websocket.Conn) error

type Client

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

func NewClient

func NewClient(id string, token string, conn *websocket.Conn) *Client

func (*Client) CloseManually

func (c *Client) CloseManually() error

func (*Client) GetId

func (c *Client) GetId() string

func (*Client) GetToken

func (c *Client) GetToken() string

func (*Client) ReadMessage

func (c *Client) ReadMessage() (*protocol.Message, error)

func (*Client) SendMessageManually

func (c *Client) SendMessageManually(msg *protocol.Message) error

func (*Client) StartMessageLoop

func (c *Client) StartMessageLoop(onClose BeforeCloseCallback) error

func (*Client) UpdateTimeout

func (c *Client) UpdateTimeout(deadline time.Time) error

UpdateTimeout sets the deadline for the next message. Signaling handlers call it after receiving a heartbeat or forwarded message, before the next read.

type ClientManager

type ClientManager struct {
	MaxClients uint // Maximum number of clients
	// contains filtered or unexported fields
}

ClientManager is responsible for handling all connected clients.

func NewClientManager

func NewClientManager(maxClient uint) *ClientManager

func (*ClientManager) AddClient

func (cm *ClientManager) AddClient(c *Client) error

func (*ClientManager) Clear

func (cm *ClientManager) Clear()

func (*ClientManager) ListClients

func (cm *ClientManager) ListClients() []string

func (*ClientManager) RemoveClient

func (cm *ClientManager) RemoveClient(c *Client)

func (*ClientManager) SendToClient

func (cm *ClientManager) SendToClient(id string, msg *protocol.Message) (bool, error)

func (*ClientManager) SendToClientBatch

func (cm *ClientManager) SendToClientBatch(id string, msg utils.Iterable[*protocol.Message]) (bool, error)

func (*ClientManager) SendToMultiClientBatch

func (cm *ClientManager) SendToMultiClientBatch(v map[string]utils.Iterable[*protocol.Message]) (map[string]bool, error)

func (*ClientManager) SendToMultiClientBatchContext

func (cm *ClientManager) SendToMultiClientBatchContext(ctx context.Context, v map[string]utils.Iterable[*protocol.Message]) (map[string]bool, error)

SendToMultiClientBatchContext releases the read lock when delivery is canceled.

type IdTakenError

type IdTakenError struct {
}

func (IdTakenError) Error

func (e IdTakenError) Error() string

type InvalidClientError

type InvalidClientError struct {
}

func (InvalidClientError) Error

func (e InvalidClientError) Error() string

type OneOrMoreMsg

type OneOrMoreMsg struct {
	One  *protocol.Message
	More utils.Iterable[*protocol.Message]
}

type TooManyClientsError

type TooManyClientsError struct {
	Count uint
}

func (TooManyClientsError) Error

func (e TooManyClientsError) Error() string

Jump to

Keyboard shortcuts

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