Documentation ¶
Index ¶
- type CloseEvent
- type State
- type WebSocket
- func (ws *WebSocket) Close()
- func (ws *WebSocket) Closed() bool
- func (ws *WebSocket) OnClose(cb func(*CloseEvent)) *WebSocket
- func (ws *WebSocket) OnError(cb func(*js.Event)) *WebSocket
- func (ws *WebSocket) OnMessage(cb func([]byte)) *WebSocket
- func (ws *WebSocket) OnOpen(cb func(*js.Event)) *WebSocket
- func (ws *WebSocket) ReadyState() State
- func (ws *WebSocket) Release()
- func (ws *WebSocket) SendBinary(data interface{}) *WebSocket
- func (ws *WebSocket) SendText(data string) *WebSocket
- func (ws *WebSocket) URL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloseEvent ¶
CloseEvent represents javascript close event. https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent.
func (*CloseEvent) Reason ¶
func (e *CloseEvent) Reason() string
Reason returns eht reason the server closed the connection.
func (*CloseEvent) WasClean ¶
func (e *CloseEvent) WasClean() bool
WasClean returns a boolean that indicates whether or not the connection was cleanly closed.
type State ¶
type State uint16
State represents websocket ready state.
websocket ready state valeus.
type WebSocket ¶
type WebSocket struct {
// contains filtered or unexported fields
}
WebSocket represents javascript web socket component.
func (*WebSocket) Closed ¶
Closed returns boolean that indicates whether or not the connection was closed.
func (*WebSocket) OnClose ¶
func (ws *WebSocket) OnClose(cb func(*CloseEvent)) *WebSocket
OnClose add callback function when closed.
func (*WebSocket) ReadyState ¶
ReadyState returns current ready state.
func (*WebSocket) Release ¶
func (ws *WebSocket) Release()
Release closes connection and frees up resources.
func (*WebSocket) SendBinary ¶
SendBinary sends binary data to server. Parameter data must be []int8, []int16, []int32, []uint8, []uint16, []uint32, []float32 and []float64.