websocket

package
v0.0.0-...-0db0fbe Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultReadTimeout = time.Minute
View Source
const DefaultWriteTimeout = time.Minute
View Source
const MsgTypeBinary = websocket.BinaryMessage

MsgTypeBinary binary message type

View Source
const MsgTypeText = websocket.TextMessage

MsgTypeText text message type

Variables

View Source
var ErrMsgTypeNotMatch = errors.New("websocket message type not match")

ErrMsgTypeNotMatch error message type not match

View Source
var Upgrader = websocket.Upgrader{}

Upgrader websocket connection upgrader config

Functions

This section is empty.

Types

type Conn

type Conn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

Conn websocket connection

func New

func New() *Conn

New create new websocket connection. Return connection created.

func Upgrade

func Upgrade(w http.ResponseWriter, r *http.Request, opt *Options) (*Conn, error)

Upgrade Upgrade http requret with given message type to websocket concection. Return websocker connection and any error if raised.

func (*Conn) C

func (c *Conn) C() chan int

C connection close signal chan.

func (*Conn) Close

func (c *Conn) Close() error

Close close connection. Return any error if raised.

func (*Conn) ErrorsChan

func (c *Conn) ErrorsChan() chan error

ErrorsChan connection error chan.

func (*Conn) MessagesChan

func (c *Conn) MessagesChan() chan []byte

MessagesChan connection message chan

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr return connection rempte address.

func (*Conn) Send

func (c *Conn) Send(msg []byte) error

Send send message to connction. return any error if raised.

type Options

type Options struct {
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	MsgType      int
}

func NewOptions

func NewOptions() *Options

Jump to

Keyboard shortcuts

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