ws

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WebsocketConnection

type WebsocketConnection struct {
	// contains filtered or unexported fields
}

Connection is a Websocket connection

func NewWebsocketConnection

func NewWebsocketConnection(scheme, host, path string, headers http.Header) (*WebsocketConnection, error)

NewWebsocketConnection creates a new Websocket connection

func (*WebsocketConnection) Close

func (wc *WebsocketConnection) Close() error

Close closes the Websocket connection

func (*WebsocketConnection) Read

func (wc *WebsocketConnection) Read() (int, []byte, error)

ReadMessage reads a message from the Websocket server

func (*WebsocketConnection) Send

func (wc *WebsocketConnection) Send(messageType int, data []byte) error

Send sends a message to the Websocket server messageType is based on Gorilla's message types https://pkg.go.dev/github.com/gorilla/websocket#pkg-constants

func (*WebsocketConnection) SetPingHandler

func (wc *WebsocketConnection) SetPingHandler(handler func(data string) error)

SetPingHandler sets a handler for ping messages

func (*WebsocketConnection) SetPongHandler

func (wc *WebsocketConnection) SetPongHandler(handler func(data string) error)

SetPongHandler sets a handler for pong messages

Jump to

Keyboard shortcuts

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