websocket

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package websocket provides the scriptling.net.websocket client library.

Index

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

func Register

func Register(registrar interface{ RegisterLibrary(*object.Library) }, cfg ...*netsecurity.Config)

Register registers the WebSocket client library. An optional network policy guards the outbound dial.

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

func (c *WebSocketClientConn) ReadWithTimeout(timeout time.Duration) (int, []byte, error)

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

Jump to

Keyboard shortcuts

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