Documentation
¶
Index ¶
- func DebugMode()
- type Conn
- func (c *Conn) Close()
- func (c *Conn) Connected() bool
- func (c *Conn) GetExtra() interface{}
- func (c *Conn) ID() string
- func (c *Conn) RemoteAddr() string
- func (c *Conn) Request() *http.Request
- func (c *Conn) SendEvent(uri string, event interface{}) error
- func (c *Conn) SetExtra(extra interface{})
- func (c *Conn) StringMode()
- type EventHandler
- type PubHandler
- type RPCHandler
- type SubHandler
- type Wango
- func (w *Wango) Call(uri string, data ...interface{}) (interface{}, error)
- func (w *Wango) Disconnect()
- func (w *Wango) GetConnection(id string) (*Conn, error)
- func (w *Wango) Publish(uri string, event interface{})
- func (w *Wango) RegisterRPCHandler(_uri interface{}, ...) error
- func (w *Wango) RegisterSubHandler(uri string, ...) error
- func (w *Wango) SendEvent(uri string, event interface{}, connIDs []string)
- func (w *Wango) SetSessionCloseCallback(cb func(*Conn))
- func (w *Wango) SetSessionOpenCallback(cb func(*Conn))
- func (w *Wango) StringMode()
- func (w *Wango) Subscribe(uri string, fn func(uri string, event interface{}), id ...string) error
- func (w *Wango) Unsubscribe(uri string, id ...string) error
- func (w *Wango) WampHandler(ws *websocket.Conn, extra interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugMode ¶
func DebugMode()
DebugMode sets debug flag after that will print debug messages to stdout
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a websocket connection
func (*Conn) Connected ¶
Connected returns true if websocket connection established and not closed
func (*Conn) GetExtra ¶
func (c *Conn) GetExtra() interface{}
GetExtra returns extra data stored in connection
func (*Conn) SendEvent ¶
SendEvent sends event for provided uri directly to connection
type EventHandler ¶
type EventHandler func(uri string, event interface{})
EventHandler is an interface for handlers to published events. The uri is the URI of the event and event is the event centents.
type PubHandler ¶
PubHandler describes func for handling publish event before sending to subscribers
type RPCHandler ¶
RPCHandler describes func for handling RPC requests
type SubHandler ¶
SubHandler describes func for handling RPC requests
type Wango ¶
type Wango struct {
// contains filtered or unexported fields
}
Wango represents a WAMP server that handles RPC and pub/sub.
func Connect ¶
Connect connects to server with provided URI and origin
func New ¶
New creates new Wango and returns pointer to it
func (*Wango) Call ¶
Call used for call RPC
func (*Wango) Disconnect ¶
func (w *Wango) Disconnect()
Disconnect used to disconnect all clients in server mode, or to disconnect from server in client mode
func (*Wango) GetConnection ¶
GetConnection returns connection for connID provided.
func (*Wango) Publish ¶
Publish used for publish event
func (*Wango) RegisterRPCHandler ¶
func (w *Wango) RegisterRPCHandler(_uri interface{}, fn func(c *Conn, uri string, args ...interface{}) (interface{}, error)) error
RegisterRPCHandler registers RPC handler function for provided URI
func (*Wango) RegisterSubHandler ¶
func (w *Wango) RegisterSubHandler(uri string, fnSub func(c *Conn, uri string, args ...interface{}) (interface{}, error), fnUnsub func(c *Conn, uri string, args ...interface{}) (interface{}, error), fnPub func(uri string, event interface{}, extra interface{}) (bool, interface{})) error
RegisterSubHandler registers subscription handler function for provided URI. fnSub, fnUnsub and fnPub can be nil. fnSub will called when subscribe event arrived. fnUnsub will called when unsubscribe event arrived. fnPub will called when called Publish method. It can control sending event to connections. If first returned argument is true, then to connection will send data from second argument.
func (*Wango) SendEvent ¶
SendEvent sends event for provided uri directly to receivers in slice connIDs
func (*Wango) SetSessionCloseCallback ¶
SetSessionCloseCallback sets callback that will called when connection will closed Callback passes connection struct as only argument.
func (*Wango) SetSessionOpenCallback ¶
SetSessionOpenCallback sets callback that will called when new connection will established. Callback passes connection struct as only argument.
func (*Wango) StringMode ¶
func (w *Wango) StringMode()
StringMode sets a string mode to use TextFrame encoding for sending messages
func (*Wango) Subscribe ¶
Subscribe sends subscribe request for uri provided.
func (*Wango) Unsubscribe ¶
Unsubscribe sends unsubscribe request for uri provided
Source Files
¶
- client.go
- conn.go
- interfaces.go
- msg.go
- parser.go
- wamp.go
- wango.go