Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Frame ¶
type Frame struct { Path string `json:"path,omitempty"` Channel string `json:"channel,omitempty"` Data enc.Map `json:"data,omitempty"` Error string `json:"error,omitempty"` Tracking string `json:"tracking-id,omitempty"` }
The frame used internally to route the custom data using Path anc Channel
type Handler ¶
type Handler[State any] struct { // optional callback fired on connection. OnConnect func(c ctx.C, conn *Conn[State]) // fired when a shutdown start, if empty it will send `"shutdown"` to the client OnShutdown func(c ctx.C, conn *Conn[State]) // contains filtered or unexported fields }
Handler is used to define a websocket. It tells on which path to mount it, what to do on connect and which object should be expected to be processed
func New ¶
Build a new Websocket handler, which support the given operations. Note: the given Op objects might not have an `api:"url"` field, in which case the Object name will be used
func (Handler[State]) NewClient ¶
func (h Handler[State]) NewClient(c ctx.C, send func(ctx.C, enc.Node) error, fallback func(ctx.C, enc.Node) error) *Client[State]
create a client for this websocket, you must provide a way to send data to the server, and the fallback for any messages which are not a reply to our requests
func (*Handler[State]) ServeHTTP ¶
func (this *Handler[State]) ServeHTTP(w gohttp.ResponseWriter, r *gohttp.Request)
func (*Handler[State]) TestClient ¶
func (this *Handler[State]) TestClient(c ctx.C) *TestClient[State]
creates a TestClient which can be used to locally test a client against a websocket implementation the websocket will run on its own separate thread
type TestClient ¶
type TestClient[State any] struct { *Client[State] Conn *Conn[State] // contains filtered or unexported fields }
func (*TestClient[State]) Close ¶
func (this *TestClient[State]) Close() error