Documentation ¶
Index ¶
Constants ¶
View Source
const ( WSMessageBufferSize = 100 HeaderPartsNumber = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶ added in v0.2.0
type Connection struct {
// contains filtered or unexported fields
}
func NewWS ¶
func NewWS(wsURL string, opts Options) (*Connection, error)
NewWS creates a new WebSocket connection to the specified URL with the given options. It returns a Connection object and an error if any occurred.
func (*Connection) Close ¶ added in v0.2.0
func (wsInsp *Connection) Close()
Close closes the WebSocket connection. If the connection is already closed, it returns immediately.
func (*Connection) Hostname ¶ added in v0.3.0
func (wsInsp *Connection) Hostname() string
Hostname returns the hostname of the WebSocket server.
func (*Connection) Messages ¶ added in v0.2.0
func (wsInsp *Connection) Messages() <-chan Message
Messages returns a channel that receives messages from the WebSocket connection.
func (*Connection) Send ¶ added in v0.2.0
func (wsInsp *Connection) Send(msg string) (*Message, error)
Send sends a message to the websocket connection and returns a Message and an error. It takes a string message as input and returns a pointer to a Message struct and an error. The Message struct contains the message type and data.
type ConnectionHandler ¶ added in v0.3.1
type Message ¶
type Message struct { Data string `json:"data"` Type MessageType `json:"type"` }
type MessageType ¶
type MessageType uint8
const ( NotDefined MessageType = iota Request Response )
func (MessageType) String ¶ added in v0.2.0
func (mt MessageType) String() string
Click to show internal directories.
Click to hide internal directories.