Documentation ¶
Rendered for js/wasm
Overview ¶
Package wsjs implements typed access to the browser javascript WebSocket API.
Index ¶
- type CloseEvent
- type MessageEvent
- type WebSocket
- func (c WebSocket) Close(code int, reason string) (err error)
- func (c WebSocket) OnClose(fn func(CloseEvent)) (remove func())
- func (c WebSocket) OnError(fn func(e js.Value)) (remove func())
- func (c WebSocket) OnMessage(fn func(m MessageEvent)) (remove func())
- func (c WebSocket) OnOpen(fn func(e js.Value)) (remove func())
- func (c WebSocket) SendBytes(v []byte) (err error)
- func (c WebSocket) SendText(v string) (err error)
- func (c WebSocket) Subprotocol() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloseEvent ¶
CloseEvent is the type passed to a WebSocket close handler.
type MessageEvent ¶
type MessageEvent struct {
// string or []byte.
Data interface{}
}
MessageEvent is the type passed to a message handler.
type WebSocket ¶
type WebSocket struct {
// contains filtered or unexported fields
}
WebSocket is a wrapper around a javascript WebSocket object.
func (WebSocket) OnClose ¶
func (c WebSocket) OnClose(fn func(CloseEvent)) (remove func())
OnClose registers a function to be called when the WebSocket is closed.
func (WebSocket) OnError ¶
OnError registers a function to be called when there is an error with the WebSocket.
func (WebSocket) OnMessage ¶
func (c WebSocket) OnMessage(fn func(m MessageEvent)) (remove func())
OnMessage registers a function to be called when the WebSocket receives a message.
func (WebSocket) SendBytes ¶
SendBytes sends the given message as a binary message on the WebSocket.
func (WebSocket) Subprotocol ¶
Subprotocol returns the WebSocket subprotocol in use.
Click to show internal directories.
Click to hide internal directories.