Documentation
¶
Index ¶
Constants ¶
Variables ¶
View Source
var ( ErrorBinaryMessage = errors.New("Binary messages are not supported") ErrorBadBuffer = errors.New("Buffer error") ErrorPacketWrong = errors.New("Wrong packet type error") ErrorMethodNotAllowed = errors.New("Method not allowed") ErrorHttpUpgradeFailed = errors.New("Http upgrade failed") )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface {
/**
Receive one more message, block until received
*/
GetMessage() (message string, err error)
/**
Send given message, block until sent
*/
WriteMessage(message string) error
/**
Close current connection
*/
Close()
/**
Get ping time interval and ping request timeout
*/
PingParams() (interval, timeout time.Duration)
}
* End-point connection for given transport
type Transport ¶
type Transport interface {
/**
Get client connection
*/
Connect(url string) (conn Connection, err error)
/**
Handle one server connection
*/
HandleConnection(w http.ResponseWriter, r *http.Request) (conn Connection, err error)
/**
Serve HTTP request after making connection and events setup
*/
Serve(w http.ResponseWriter, r *http.Request)
}
* Connection factory for given transport
type WebsocketConnection ¶
type WebsocketConnection struct {
// contains filtered or unexported fields
}
func (*WebsocketConnection) Close ¶
func (wsc *WebsocketConnection) Close()
func (*WebsocketConnection) GetMessage ¶
func (wsc *WebsocketConnection) GetMessage() (message string, err error)
func (*WebsocketConnection) PingParams ¶
func (wsc *WebsocketConnection) PingParams() (interval, timeout time.Duration)
func (*WebsocketConnection) WriteMessage ¶
func (wsc *WebsocketConnection) WriteMessage(message string) error
type WebsocketTransport ¶
type WebsocketTransport struct {
PingInterval time.Duration
PingTimeout time.Duration
ReceiveTimeout time.Duration
SendTimeout time.Duration
BufferSize int
RequestHeader http.Header
}
func GetDefaultWebsocketTransport ¶
func GetDefaultWebsocketTransport() *WebsocketTransport
* Returns websocket connection with default params
func (*WebsocketTransport) Connect ¶
func (wst *WebsocketTransport) Connect(url string) (conn Connection, err error)
func (*WebsocketTransport) HandleConnection ¶
func (wst *WebsocketTransport) HandleConnection( w http.ResponseWriter, r *http.Request) (conn Connection, err error)
func (*WebsocketTransport) Serve ¶
func (wst *WebsocketTransport) Serve(w http.ResponseWriter, r *http.Request)
* Websocket connection do not require any additional processing
Click to show internal directories.
Click to hide internal directories.