transport

package
v0.0.0-...-2c44953 Latest Latest
Warning

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

Go to latest
Published: May 10, 2017 License: GPL-3.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WsDefaultPingInterval   = 30 * time.Second
	WsDefaultPingTimeout    = 60 * time.Second
	WsDefaultReceiveTimeout = 60 * time.Second
	WsDefaultSendTimeout    = 60 * time.Second
	WsDefaultBufferSize     = 1024 * 32
)

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

* Websocket connection do not require any additional processing

Jump to

Keyboard shortcuts

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