ws

package
v0.0.0-...-6e88d74 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WSReadyState_CONNECTING WSReadyState = 0
	WSReadyState_OPEN                    = 1
	WSReadyState_CLOSING                 = 2
	WSReadyState_CLOSED                  = 3
)

Variables

This section is empty.

Functions

func GetByteSliceFromWSMessageEvent

func GetByteSliceFromWSMessageEvent(
	event js.Value,
) (
	[]byte,
	error,
)

func GetByteSliceFromWSMessageEventData

func GetByteSliceFromWSMessageEventData(
	event_data js.Value,
) (
	[]byte,
	error,
)

Types

type EmptyStruct

type EmptyStruct struct{}

type WS

type WS struct {
	JSValue js.Value
	// contains filtered or unexported fields
}

func NewWS

func NewWS(options *WSOptions) (res *WS, err error)

func (*WS) BinaryTypeGet

func (self *WS) BinaryTypeGet() (ret string, err error)

func (*WS) BinaryTypeSet

func (self *WS) BinaryTypeSet(value string) (err error)

func (*WS) BufferedAmountGet

func (self *WS) BufferedAmountGet() (ret int, err error)

func (*WS) Close

func (self *WS) Close() error

func (*WS) CloseWithCode

func (self *WS) CloseWithCode(code int) error

func (*WS) CloseWithCodeAndReason

func (self *WS) CloseWithCodeAndReason(code int, reason string) error

func (*WS) ProtocolGet

func (self *WS) ProtocolGet() (ret string, err error)

func (*WS) ReadyStateGet

func (self *WS) ReadyStateGet() (ret WSReadyState, err error)

func (*WS) Send

func (self *WS) Send(value js.Value) (err error)

func (*WS) SetOnClose

func (self *WS) SetOnClose(f func(*events.CloseEvent)) (err error)

func (*WS) SetOnError

func (self *WS) SetOnError(f func(*events.ErrorEvent)) (err error)

func (*WS) SetOnMessage

func (self *WS) SetOnMessage(f func(*events.MessageEvent)) (err error)

func (*WS) SetOnOpen

func (self *WS) SetOnOpen(f func(*events.Event)) (err error)

func (*WS) URLGet

func (self *WS) URLGet() (ret string, err error)

type WSNetConn

type WSNetConn struct {
	WSError error
	// contains filtered or unexported fields
}

func NewWSNetConn

func NewWSNetConn(options *WSNetConnOptions) *WSNetConn

func (*WSNetConn) Close

func (self *WSNetConn) Close() error

func (*WSNetConn) GetWorker

func (self *WSNetConn) GetWorker() goworker.WorkerI

func (*WSNetConn) InstallEventHandlersIntoWS

func (self *WSNetConn) InstallEventHandlersIntoWS() error

func (*WSNetConn) LocalAddr

func (self *WSNetConn) LocalAddr() net.Addr

func (*WSNetConn) Read

func (self *WSNetConn) Read(b []byte) (n int, err error)

func (*WSNetConn) RemoteAddr

func (self *WSNetConn) RemoteAddr() net.Addr

func (*WSNetConn) SetDeadline

func (self *WSNetConn) SetDeadline(t time.Time) error

func (*WSNetConn) SetReadDeadline

func (self *WSNetConn) SetReadDeadline(t time.Time) error

func (*WSNetConn) SetWriteDeadline

func (self *WSNetConn) SetWriteDeadline(t time.Time) error

func (*WSNetConn) Write

func (self *WSNetConn) Write(b []byte) (n int, err error)

type WSNetConnOptions

type WSNetConnOptions struct {
	WS          *WS
	CloseCode   *int
	CloseReason *string
	OnError     func(error)
}

type WSOptions

type WSOptions struct {
	URL *string
	// to use existing ws
	JSValue   *js.Value
	Protocols []string

	OnClose   func(*events.CloseEvent)   // function(event)
	OnError   func(*events.ErrorEvent)   // function(event)
	OnMessage func(*events.MessageEvent) // function(event)
	OnOpen    func(*events.Event)        // function(event)
}

if both url and js_value are specified, js_value is used

type WSReadyState

type WSReadyState int

Jump to

Keyboard shortcuts

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