wsconn

package
v0.0.0-...-7a50bc8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWebsocketConnection

func NewWebsocketConnection(ws Conn) net.Conn

Returns a websocket connection wrapper to the net.Conn interface.

Types

type Conn

type Conn interface {
	WriteControl(messageType int, data []byte, deadline time.Time) error
	NextReader() (messageType int, r io.Reader, err error)
	NextWriter(messageType int) (io.WriteCloser, error)

	LocalAddr() net.Addr
	RemoteAddr() net.Addr

	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error

	Close() error
}

Conn is an interface which a websocket library should implement to be compatible with this wrapper.

type WebsocketConnection

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

WebsocketConnection is a wrapper around a websocket connect from a lower level API. It supports things such as automatic ping/pong keepalive.

func (*WebsocketConnection) Close

func (conn *WebsocketConnection) Close() error

Closes the connection and exits from the ping loop.

func (*WebsocketConnection) GetTextChannel

func (conn *WebsocketConnection) GetTextChannel() <-chan []byte

GetTextChannel returns a channel outputting all text messages from the websocket.

func (*WebsocketConnection) LocalAddr

func (conn *WebsocketConnection) LocalAddr() net.Addr

LocalAddr returns the local net.Addr of the websocket connection.

func (*WebsocketConnection) Read

func (conn *WebsocketConnection) Read(b []byte) (n int, err error)

Reads slice of bytes off of the websocket connection.

func (*WebsocketConnection) RemoteAddr

func (conn *WebsocketConnection) RemoteAddr() net.Addr

RemoteAddr returns the remote net.Addr of the websocket connection.

func (*WebsocketConnection) SetDeadline

func (conn *WebsocketConnection) SetDeadline(t time.Time) error

SetDeadline the read and write deadlines associated with the connection.

func (*WebsocketConnection) SetReadDeadline

func (conn *WebsocketConnection) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline associated with the connection.

func (*WebsocketConnection) SetWriteDeadline

func (conn *WebsocketConnection) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline assocated with the connection.

func (*WebsocketConnection) Write

func (conn *WebsocketConnection) Write(b []byte) (n int, err error)

Writes the given bytes as a binary opcode segment onto the websocket.

Jump to

Keyboard shortcuts

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