Documentation
¶
Overview ¶
Package websocket provides the scriptling.net.websocket client library.
Index ¶
- Constants
- Variables
- func Register(registrar interface{ ... }, cfg ...*netsecurity.Config)
- type WebSocketClientConn
- func (c *WebSocketClientConn) Close() error
- func (c *WebSocketClientConn) ClosedChan() <-chan struct{}
- func (c *WebSocketClientConn) IsConnected() bool
- func (c *WebSocketClientConn) ReadWithTimeout(timeout time.Duration) (int, []byte, error)
- func (c *WebSocketClientConn) RemoteAddr() string
- func (c *WebSocketClientConn) WriteMessage(msgType int, data []byte) error
Constants ¶
View Source
const LibraryName = "scriptling.net.websocket"
LibraryName is the script-visible name of the WebSocket client library.
Variables ¶
View Source
var WebSocketLibrary = newWebSocketLibrary(nil)
WebSocketLibrary is the WebSocket client library (no network policy)
Functions ¶
Types ¶
type WebSocketClientConn ¶
type WebSocketClientConn struct {
// contains filtered or unexported fields
}
WebSocketClientConn wraps a websocket.Conn with thread-safe access
func NewWebSocketClientConn ¶
func NewWebSocketClientConn(conn *websocket.Conn) *WebSocketClientConn
NewWebSocketClientConn creates a new wrapped WebSocket connection
func (*WebSocketClientConn) Close ¶
func (c *WebSocketClientConn) Close() error
Close closes the connection
func (*WebSocketClientConn) ClosedChan ¶
func (c *WebSocketClientConn) ClosedChan() <-chan struct{}
ClosedChan returns a channel that closes when the connection closes
func (*WebSocketClientConn) IsConnected ¶
func (c *WebSocketClientConn) IsConnected() bool
IsConnected returns whether the connection is still open
func (*WebSocketClientConn) ReadWithTimeout ¶
ReadWithTimeout reads a message with a timeout Returns messageType, data, error. On timeout, returns 0, nil, nil
func (*WebSocketClientConn) RemoteAddr ¶
func (c *WebSocketClientConn) RemoteAddr() string
RemoteAddr returns the remote address
func (*WebSocketClientConn) WriteMessage ¶
func (c *WebSocketClientConn) WriteMessage(msgType int, data []byte) error
WriteMessage sends a message
Click to show internal directories.
Click to hide internal directories.