ws

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInfo

type ClientInfo struct {
	User    string
	IPAddr  string
	Headers http.Header
}

type ClientMessage

type ClientMessage struct {
	ConnID     string
	ClientInfo *ClientInfo
	Message    *syftmsg.Message
}

type WebsocketClient

type WebsocketClient struct {
	ConnID string
	Info   *ClientInfo
	MsgRx  chan *syftmsg.Message
	MsgTx  chan *syftmsg.Message
	Closed chan struct{}
	// contains filtered or unexported fields
}

WebsocketClient represents a connected WebSocket client.

func NewWebsocketClient

func NewWebsocketClient(conn *websocket.Conn, info *ClientInfo) *WebsocketClient

func (*WebsocketClient) Close

func (c *WebsocketClient) Close()

func (*WebsocketClient) Start

func (c *WebsocketClient) Start(ctx context.Context)

type WebsocketHub

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

func NewHub

func NewHub() *WebsocketHub

func (*WebsocketHub) Broadcast

func (h *WebsocketHub) Broadcast(msg *syftmsg.Message)

func (*WebsocketHub) BroadcastFiltered

func (h *WebsocketHub) BroadcastFiltered(msg *syftmsg.Message, predicate func(*ClientInfo) bool)

BroadcastFiltered sends a message to all clients that match the filter

func (*WebsocketHub) Messages

func (h *WebsocketHub) Messages() <-chan *ClientMessage

OnMessage registers a handler function that gets called when a client sends a message

func (*WebsocketHub) Run

func (h *WebsocketHub) Run(ctx context.Context)

func (*WebsocketHub) SendMessage

func (h *WebsocketHub) SendMessage(connId string, msg *syftmsg.Message)

func (*WebsocketHub) SendMessageUser

func (h *WebsocketHub) SendMessageUser(user string, msg *syftmsg.Message) bool

SendMessageUser sends a message to all clients with the specified username

func (*WebsocketHub) Shutdown

func (h *WebsocketHub) Shutdown(ctx context.Context)

func (*WebsocketHub) WebsocketHandler

func (h *WebsocketHub) WebsocketHandler(ctx *gin.Context)

WebsocketHandler is the handler for the websocket connection it upgrades the http connection to a websocket and registers the client with the hub

Jump to

Keyboard shortcuts

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