Documentation ¶
Overview ¶
Package turnpike provides a Websocket Application Messaging Protocol (WAMP) server and client
Package turnpike provides a Websocket Application Messaging Protocol (WAMP) server and client
Index ¶
- Constants
- Variables
- func CheckCurie(pm PrefixMap, curie string) string
- func CreateCall(callID, procURI string, args ...interface{}) (string, error)
- func CreateCallError(callID, errorURI, errorDesc string, errorDetails ...interface{}) (string, error)
- func CreateCallResult(callID string, result interface{}) (string, error)
- func CreateEvent(topicURI string, event interface{}) (string, error)
- func CreatePrefix(prefix, URI string) (string, error)
- func CreatePublish(topicURI string, event interface{}, opts ...interface{}) (string, error)
- func CreateSubscribe(topicURI string) (string, error)
- func CreateUnsubscribe(topicURI string) (string, error)
- func CreateWelcome(sessionId, serverIdent string) (string, error)
- func HandleWebsocket(t Handler) func(*websocket.Conn)
- func ParseType(msg string) int
- func SetLogger(newLog lumber.Logger)
- func TypeString(typ int) string
- type CallErrorMsg
- type CallMsg
- type CallResultMsg
- type Client
- func (c *Client) Call(callID, procURI string, args ...interface{}) error
- func (c *Client) Connect(server, origin string) error
- func (c *Client) Listen()
- func (c *Client) Prefix(prefix, URI string) error
- func (c *Client) Publish(topicURI string, event interface{}, opts ...interface{}) error
- func (c *Client) PublishExcludeMe(topicURI string, event interface{}) error
- func (c *Client) ReceiveWelcome() error
- func (c *Client) Send()
- func (c *Client) Subscribe(topicURI string) error
- func (c *Client) Unsubscribe(topicURI string) error
- type EventMsg
- type Handler
- type PrefixMap
- type PrefixMsg
- type PublishMsg
- type RPCError
- type RPCHandler
- type Server
- type SubscribeMsg
- type UnsubscribeMsg
- type WAMPError
- type WelcomeMsg
Constants ¶
const ( CLIENT_CONN_TIMEOUT = 6 CLIENT_MAX_FAILURES = 3 )
const ( TURNPIKE_VERSION = "0.2.0" TURNPIKE_SERVER_IDENT = "turnpike-" + TURNPIKE_VERSION )
const ( WELCOME = iota PREFIX CALL CALLRESULT CALLERROR SUBSCRIBE UNSUBSCRIBE PUBLISH EVENT )
const PROTOCOL_VERSION = 1
const (
WAMP_SUBPROTOCOL_ID = "wamp"
)
Variables ¶
var ( ErrInvalidURI = &WAMPError{"invalid URI"} ErrInvalidNumArgs = &WAMPError{"invalid number of arguments in message"} ErrUnsupportedProtocol = &WAMPError{"unsupported protocol"} )
Functions ¶
func CheckCurie ¶
convenience function that will resolve a curie and pass through a URI
func CreateCall ¶
Call returns a json encoded WAMP 'CALL' message as a byte slice callID must be a randomly generated string, procURI is the URI of the remote procedure to be called, followed by zero or more call arguments
func CreateCallError ¶
func CreateCallError(callID, errorURI, errorDesc string, errorDetails ...interface{}) (string, error)
CallError returns a json encoded WAMP 'CALLERROR' message as a byte slice callID is the randomly generated string provided by the client, errorURI is a URI identifying the error, errorDesc is a human-readable description of the error (for developers), errorDetails, if present, is a non-nil object
func CreateCallResult ¶
CallResult returns a json encoded WAMP 'CALLRESULT' message as a byte slice callID is the randomly generated string provided by the client
func CreateEvent ¶
Event returns a json encoded WAMP 'EVENT' message as a byte slice event can be nil, a simple json type, or a complex json type
func CreatePrefix ¶
Prefix returns a json encoded WAMP 'PREFIX' message as a byte slice
func CreatePublish ¶
Publish returns a json encoded WAMP 'PUBLISH' message as a byte slice arguments must be given in one of the following formats: [ topicURI, event ] [ topicURI, event, excludeMe ] [ topicURI, event, exclude ] [ topicURI, event, exclude, eligible ] event can be nil, a simple json type, or a complex json type
func CreateSubscribe ¶
Subscribe returns a json encoded WAMP 'SUBSCRIBE' message as a byte slice topicURI is the topic that the client wants to subscribe to
func CreateUnsubscribe ¶
Unsubscribe returns a json encoded WAMP 'UNSUBSCRIBE' message as a byte slice topicURI is the topic that the client wants to unsubscribe from
func CreateWelcome ¶
Welcome returns a json encoded WAMP 'WELCOME' message as a byte slice sessionId is a randomly generated string provided by the server, serverIdent is a string that identifies the WAMP server
func HandleWebsocket ¶
HandleWebsocket is a Go1.0 shim for method values
func TypeString ¶
Types ¶
type CallErrorMsg ¶
type CallErrorMsg struct { CallID string ErrorURI string ErrorDesc string ErrorDetails interface{} }
CALLERROR
func (*CallErrorMsg) UnmarshalJSON ¶
func (msg *CallErrorMsg) UnmarshalJSON(jsonData []byte) error
type CallResultMsg ¶
type CallResultMsg struct { CallID string Result interface{} }
CALLRESULT
func (*CallResultMsg) UnmarshalJSON ¶
func (msg *CallResultMsg) UnmarshalJSON(jsonData []byte) error
type Client ¶
type Client struct { SessionId string ProtocolVersion int ServerIdent string // contains filtered or unexported fields }
func (*Client) PublishExcludeMe ¶
func (*Client) ReceiveWelcome ¶
func (*Client) Unsubscribe ¶
type EventMsg ¶
type EventMsg struct { TopicURI string Event interface{} }
EVENT
func (*EventMsg) UnmarshalJSON ¶
type PrefixMap ¶
func (PrefixMap) RegisterPrefix ¶
type PublishMsg ¶
type PublishMsg struct { TopicURI string Event interface{} ExcludeMe bool ExcludeList []string EligibleList []string }
PUBLISH
func (*PublishMsg) UnmarshalJSON ¶
func (msg *PublishMsg) UnmarshalJSON(jsonData []byte) error
type RPCHandler ¶
this may be broken in v2 if multiple-return is implemented
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) HandleWebsocket ¶
func (*Server) RegisterConnListener ¶
func (*Server) RegisterRPC ¶
func (t *Server) RegisterRPC(uri string, f RPCHandler)
func (*Server) UnregisterRPC ¶
type SubscribeMsg ¶
type SubscribeMsg struct {
TopicURI string
}
SUBSCRIBE
func (*SubscribeMsg) UnmarshalJSON ¶
func (msg *SubscribeMsg) UnmarshalJSON(jsonData []byte) error
type UnsubscribeMsg ¶
type UnsubscribeMsg struct {
TopicURI string
}
UNSUBSCRIBE
func (*UnsubscribeMsg) UnmarshalJSON ¶
func (msg *UnsubscribeMsg) UnmarshalJSON(jsonData []byte) error
type WAMPError ¶
type WAMPError struct {
Msg string
}
A WAMPError is returned when attempting to create a message that does not follow the WAMP protocol
type WelcomeMsg ¶
WELCOME
func (*WelcomeMsg) UnmarshalJSON ¶
func (msg *WelcomeMsg) UnmarshalJSON(jsonData []byte) error