Documentation
¶
Index ¶
- Constants
- Variables
- type Connection
- type Transport
- func (wst *Transport) Connect(url string) (conn *Connection, err error)
- func (wst *Transport) ConnectContext(ctx context.Context, url string) (conn *Connection, err error)
- func (wst *Transport) ConnectDialer(dialer ws.Dialer, url string) (conn *Connection, err error)
- func (wst *Transport) ConnectDialerContext(ctx context.Context, dialer ws.Dialer, url string) (conn *Connection, err error)
Constants ¶
View Source
const ( // PingInterval for the connection PingInterval = 25 * time.Second // PingTimeout for the connection PingTimeout = 60 * time.Second // ReadTimeout for the connection ReadTimeout = 60 * time.Second // SendTimeout for the connection SendTimeout = 60 * time.Second // BufferSize for the connection BufferSize = 1024 * 32 )
Variables ¶
View Source
var ( // ErrUnsupportedBinaryMessage is returned when trying to send an unsupported binary message ErrUnsupportedBinaryMessage = errors.New("sending binary messages is not supported") // ErrBadBuffer is used when there is an error while reading the buffer ErrBadBuffer = errors.New("error while reading buffer") // ErrPacketType is used when a packet comes with an unexpected format ErrPacketType = errors.New("wrong packet type") )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection to websocket
func (*Connection) GetMessage ¶
func (c *Connection) GetMessage() (data []byte, err error)
GetMessage on connection
func (*Connection) PingParams ¶
func (c *Connection) PingParams() (interval, timeout time.Duration)
PingParams gets the ping and pong interval and timeout
func (*Connection) WriteMessage ¶
func (c *Connection) WriteMessage(message string) error
WriteMessage to the socket
type Transport ¶
type Transport struct { PingInterval time.Duration PingTimeout time.Duration ReadTimeout time.Duration SendTimeout time.Duration BufferSize int Dialer ws.Dialer RequestHeader http.Header }
Transport for the websocket
func NewTransport ¶
func NewTransport() *Transport
NewTransport creates a new WebSocket connection transport
func (*Transport) Connect ¶
func (wst *Transport) Connect(url string) (conn *Connection, err error)
Connect to web socket with default gorilla websocket dialer
func (*Transport) ConnectContext ¶
ConnectContext to web socket with default gorilla websocket dialer
func (*Transport) ConnectDialer ¶
ConnectDialer to web socket
func (*Transport) ConnectDialerContext ¶
func (wst *Transport) ConnectDialerContext(ctx context.Context, dialer ws.Dialer, url string) (conn *Connection, err error)
ConnectDialerContext to web socket
Click to show internal directories.
Click to hide internal directories.