Documentation
¶
Overview ¶
Package client manages websocket client connections and their lifecycle.
Index ¶
- type ID
- type SocketUser
- type WsClient
- func (wsc *WsClient) AddSubscription(sub websocket_mod.Subscription)
- func (wsc *WsClient) ClientType() websocket_mod.ClientType
- func (wsc *WsClient) Disconnect() error
- func (wsc *WsClient) Error(err error)
- func (wsc *WsClient) GetClientID() ID
- func (wsc *WsClient) GetInstance() *tower_model.Instance
- func (wsc *WsClient) GetShortID() ID
- func (wsc *WsClient) GetSubscriptions() []websocket_mod.Subscription
- func (wsc *WsClient) GetUser() *user_model.User
- func (wsc *WsClient) IsOpen() bool
- func (wsc *WsClient) Log() *zerolog.Logger
- func (wsc *WsClient) Raw(msg any) error
- func (wsc *WsClient) ReadOne() (int, []byte, error)
- func (wsc *WsClient) RemoveSubscription(key string)
- func (wsc *WsClient) Send(msg websocket_mod.WsResponseInfo) error
- func (wsc *WsClient) SubLock()
- func (wsc *WsClient) SubUnlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SocketUser ¶
type SocketUser interface {
SocketType() websocket_mod.ClientType
}
SocketUser represents a user that can connect via websocket.
type WsClient ¶
WsClient represents a websocket client connection.
func (*WsClient) AddSubscription ¶
func (wsc *WsClient) AddSubscription(sub websocket_mod.Subscription)
AddSubscription adds a new subscription to the client.
func (*WsClient) ClientType ¶
func (wsc *WsClient) ClientType() websocket_mod.ClientType
ClientType returns the type of this client (web or tower).
func (*WsClient) Disconnect ¶
Disconnect closes the websocket connection and marks the client as inactive.
func (*WsClient) GetClientID ¶
GetClientID returns the unique identifier for this client.
func (*WsClient) GetInstance ¶
func (wsc *WsClient) GetInstance() *tower_model.Instance
GetInstance returns the tower instance associated with this client connection.
func (*WsClient) GetShortID ¶
GetShortID returns a shortened version of the client ID for display purposes.
func (*WsClient) GetSubscriptions ¶
func (wsc *WsClient) GetSubscriptions() []websocket_mod.Subscription
GetSubscriptions returns an iterator over the client's current subscriptions.
func (*WsClient) GetUser ¶
func (wsc *WsClient) GetUser() *user_model.User
GetUser returns the user associated with this client connection.
func (*WsClient) RemoveSubscription ¶
RemoveSubscription removes a subscription from the client by key.
func (*WsClient) Send ¶
func (wsc *WsClient) Send(msg websocket_mod.WsResponseInfo) error
Send sends a websocket message to the client.