Documentation ¶
Overview ¶
Package transport provides a websocket, rawsocket, and local transport implementation. The local transport is for in-process connection of a client to a router. Each transport implements the wamp.Peer interface, that connect Send and Recv methods to a particular transport.
Index ¶
- func AcceptRawSocket(conn net.Conn, logger stdlog.StdLog, recvLimit, outQueueSize int) (wamp.Peer, error)
- func ConnectRawSocketPeer(ctx context.Context, network, addr string, ...) (wamp.Peer, error)
- func ConnectWebsocketPeer(ctx context.Context, routerURL string, serialization serialize.Serialization, ...) (wamp.Peer, error)
- func LinkedPeers() (wamp.Peer, wamp.Peer)
- func LinkedPeersQSize(queueSize int) (wamp.Peer, wamp.Peer)
- func NewWebsocketPeer(conn WebsocketConnection, serializer serialize.Serializer, payloadType int, ...) wamp.Peer
- type DialFunc
- type WebsocketConfig
- type WebsocketConnection
- type WebsocketError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcceptRawSocket ¶
func AcceptRawSocket(conn net.Conn, logger stdlog.StdLog, recvLimit, outQueueSize int) (wamp.Peer, error)
AcceptRawSocket handles the client handshake and returns a rawSocketPeer.
If recvLimit is > 0, then the client will not receive messages with size larger than the nearest power of 2 greater than or equal to recvLimit. If recvLimit is <= 0, then the default of 16M is used.
func ConnectRawSocketPeer ¶
func ConnectRawSocketPeer(ctx context.Context, network, addr string, serialization serialize.Serialization, tlsConfig *tls.Config, logger stdlog.StdLog, recvLimit int) (wamp.Peer, error)
ConnectRawSocketPeer creates a new rawSocketPeer with the specified config, and connects it, to the WAMP router at the specified address. If a non-nil tlsConfig is given, then TLS is used to secure the connection. Docuemntation of tls.Config is here: https://golang.org/pkg/crypto/tls/#Config
The provided Context must be non-nil. If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection.
If recvLimit is > 0, then the client will not receive messages with size larger than the nearest power of 2 greater than or equal to recvLimit. If recvLimit is <= 0, then the default of 16M is used.
func ConnectWebsocketPeer ¶
func ConnectWebsocketPeer(ctx context.Context, routerURL string, serialization serialize.Serialization, tlsConfig *tls.Config, logger stdlog.StdLog, wsCfg *WebsocketConfig) (wamp.Peer, error)
ConnectWebsocketPeer creates a new websocket client with the specified config, connects the client to the websocket server at the specified URL, and returns the connected websocket peer.
The provided Context must be non-nil. If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection.
func LinkedPeers ¶
LinkedPeers creates two connected peers. Messages sent to one peer appear in the Recv of the other. This is used for connecting client sessions to the router.
func LinkedPeersQSize ¶ added in v3.0.2
LinkedPeersQSize is the same as LinkedPeers with the ability to specify the router-to-client queue size. Specifying size 0 uses default size.
func NewWebsocketPeer ¶
func NewWebsocketPeer(conn WebsocketConnection, serializer serialize.Serializer, payloadType int, logger stdlog.StdLog, keepAlive time.Duration, outQueueSize int) wamp.Peer
NewWebsocketPeer creates a websocket peer from an existing websocket connection. This is used by clients connecting to the WAMP router, and by servers to handle connections from clients.
A non-zero keepAlive value configures a websocket "ping/pong" heartbeat, sending websocket "pings" every keepAlive interval. If a "pong" response is not received after 2 intervals have elapsed then the websocket is closed.
Types ¶
type WebsocketConfig ¶
type WebsocketConfig struct { // Supplies alternate Dial function for the websocket dialer. // See https://godoc.org/github.com/gorilla/websocket#Dialer Dial DialFunc // Request per message write compression, if allowed by server. EnableCompression bool `json:"enable_compression"` // If provided when configuring websocket client, cookies from server are // put in here. This allows cookies to be stored and then sent back to the // server in subsequent websocket connections. Cookies may be used to // identify returning clients, and can be used to authenticate clients. Jar http.CookieJar // ProxyURL is an optional URL of the proxy to use for websocket requests. // If not defined, the proxy defined by the environment is used if defined. ProxyURL string // KeepAlive configures a websocket "ping/pong" heartbeat when set to a // non-zero value. KeepAlive is the interval between websocket "pings". // If a "pong" response is not received after 2 intervals have elapsed then // the websocket connection is closed. KeepAlive time.Duration }
WebsocketConfig is used to configure client websocket settings.
type WebsocketConnection ¶ added in v3.0.1
type WebsocketConnection interface { Close() error WriteControl(messageType int, data []byte, deadline time.Time) error WriteMessage(messageType int, data []byte) error ReadMessage() (messageType int, p []byte, err error) SetPongHandler(h func(appData string) error) SetPingHandler(h func(appData string) error) Subprotocol() string }
WebsocketConnection is the interface that a websocket connection must implement.
type WebsocketError ¶
WebsocketError is returned on failure to connect to a websocket, and contains the http response if one is available.
func (*WebsocketError) Error ¶
func (e *WebsocketError) Error() string
Error returns a string describing the failure to connect to a websocket.