Versions in this module Expand all Collapse all v1 v1.2.1 Mar 13, 2024 v1.2.0 Mar 13, 2024 Changes in this version + const WSStatsClose + const WSStatsErrPeerClosed + const WSStatsErrPeerTimeout + const WSStatsItemCount + const WSStatsNewPeer + const WSStatsRecv + const WSStatsSend + func DoneWSStats() + func InitWSStats() type Peer + func NewWebsocketPeerConfig(serialization Serialization, url string, tlscfg *tls.Config, dial DialFunc, ...) (Peer, error) type WebsocketServer + func (s *WebsocketServer) SetLogLevel(level logrus.Level) v1.1.0 Jun 19, 2018 v1.0.0 Jun 7, 2017 Changes in this version + const ErrAuthorizationFailed + const ErrCloseRealm + const ErrGoodbyeAndOut + const ErrInvalidArgument + const ErrInvalidUri + const ErrNoSuchProcedure + const ErrNoSuchRealm + const ErrNoSuchRegistration + const ErrNoSuchRole + const ErrNoSuchSubscription + const ErrNotAuthorized + const ErrProcedureAlreadyExists + const ErrSystemShutdown + const MAX_REQUEST_ID + var ErrWSIsClosed = errors.New("ws peer is closed") + var ErrWSSendTimeout = errors.New("ws peer send timeout") + type Abort struct + Details map[string]interface{} + Reason URI + func (msg *Abort) MessageType() MessageType + type AuthFunc func(map[string]interface{}, map[string]interface{}) (string, map[string]interface{}, error) + type Authenticate struct + Extra map[string]interface{} + Signature string + func (msg *Authenticate) MessageType() MessageType + type AuthenticationError string + func (e AuthenticationError) Error() string + type Authenticator interface + Authenticate func(details map[string]interface{}) (map[string]interface{}, error) + type Authorizer interface + Authorize func(session *Session, msg Message) (bool, error) + func NewDefaultAuthorizer() Authorizer + type BasicMethodHandler func(args []interface{}, kwargs map[string]interface{}) (result *CallResult) + type BinaryData []byte + func (b *BinaryData) UnmarshalJSON(arr []byte) error + func (b BinaryData) MarshalJSON() ([]byte, error) + type Broker interface + Publish func(*Session, *Publish) + RemoveSession func(*Session) + Subscribe func(*Session, *Subscribe) + Unsubscribe func(*Session, *Unsubscribe) + func NewDefaultBroker() Broker + type CRAuthenticator interface + Authenticate func(challenge map[string]interface{}, signature string) (map[string]interface{}, error) + Challenge func(details map[string]interface{}) (map[string]interface{}, error) + func NewBasicTicketAuthenticator(tickets ...string) CRAuthenticator + type Call struct + Arguments []interface{} + ArgumentsKw map[string]interface{} + Options map[string]interface{} + Procedure URI + Request ID + func (msg *Call) MessageType() MessageType + type CallResult struct + Args []interface{} + Err URI + Kwargs map[string]interface{} + type Cancel struct + Options map[string]interface{} + Request ID + func (msg *Cancel) MessageType() MessageType + type Challenge struct + AuthMethod string + Extra map[string]interface{} + func (msg *Challenge) MessageType() MessageType + type Client struct + Auth map[string]AuthFunc + ReceiveDone chan bool + ReceiveTimeout time.Duration + func NewClient(p Peer) *Client + func NewWebsocketClient(serialization Serialization, url string, tlscfg *tls.Config, dial DialFunc) (*Client, error) + func (c *Client) BasicRegister(procedure string, fn BasicMethodHandler) error + func (c *Client) Call(procedure string, options map[string]interface{}, args []interface{}, ...) (*Result, error) + func (c *Client) Close() error + func (c *Client) JoinRealm(realm string, details map[string]interface{}) (map[string]interface{}, error) + func (c *Client) LeaveRealm() error + func (c *Client) Publish(topic string, options map[string]interface{}, args []interface{}, ...) error + func (c *Client) Receive() + func (c *Client) Register(procedure string, fn MethodHandler, options map[string]interface{}) error + func (c *Client) SetLogLevel(level logrus.Level) + func (c *Client) Subscribe(topic string, options map[string]interface{}, fn EventHandler) error + func (c *Client) Unregister(procedure string) error + func (c *Client) Unsubscribe(topic string) error + type ConnectionConfig struct + IdleTimeout time.Duration + MaxMsgSize int64 + PingTimeout time.Duration + WriteTimeout time.Duration + type Dealer interface + Call func(*Session, *Call) + Error func(*Session, *Error) + Register func(*Session, *Register) + RemoveSession func(*Session) + Unregister func(*Session, *Unregister) + Yield func(*Session, *Yield) + func NewDefaultDealer() Dealer + type DialFunc func(network, addr string) (net.Conn, error) + type Error struct + Arguments []interface{} + ArgumentsKw map[string]interface{} + Details map[string]interface{} + Error URI + Request ID + Type MessageType + func (msg *Error) MessageType() MessageType + type Event struct + Arguments []interface{} + ArgumentsKw map[string]interface{} + Details map[string]interface{} + Publication ID + Subscription ID + func (msg *Event) MessageType() MessageType + type EventHandler func(args []interface{}, kwargs map[string]interface{}) + type Goodbye struct + Details map[string]interface{} + Reason URI + func (msg *Goodbye) MessageType() MessageType + type Hello struct + Details map[string]interface{} + Realm URI + func (msg *Hello) MessageType() MessageType + type ID uint64 + func NewID() ID + type Interceptor interface + Intercept func(session *Session, msg *Message) + func NewDefaultInterceptor() Interceptor + type Interrupt struct + Options map[string]interface{} + Request ID + func (msg *Interrupt) MessageType() MessageType + type Invocation struct + Arguments []interface{} + ArgumentsKw map[string]interface{} + Details map[string]interface{} + Registration ID + Request ID + func (msg *Invocation) MessageType() MessageType + type JSONSerializer struct + func (s *JSONSerializer) Deserialize(data []byte) (Message, error) + func (s *JSONSerializer) Serialize(msg Message) ([]byte, error) + type Message interface + MessageType func() MessageType + func GetMessageTimeout(p Peer, t time.Duration) (Message, error) + type MessagePackSerializer struct + func (s *MessagePackSerializer) Deserialize(data []byte) (Message, error) + func (s *MessagePackSerializer) Serialize(msg Message) ([]byte, error) + type MessageType int + const ABORT + const AUTHENTICATE + const CALL + const CANCEL + const CHALLENGE + const ERROR + const EVENT + const GOODBYE + const HELLO + const INTERRUPT + const INVOCATION + const PUBLISH + const PUBLISHED + const REGISTER + const REGISTERED + const RESULT + const SUBSCRIBE + const SUBSCRIBED + const UNREGISTER + const UNREGISTERED + const UNSUBSCRIBE + const UNSUBSCRIBED + const WELCOME + const YIELD + func (mt MessageType) New() Message + func (mt MessageType) String() string + type MethodHandler func(args []interface{}, kwargs map[string]interface{}, ...) (result *CallResult) + type NoSuchRealmError string + func (e NoSuchRealmError) Error() string + type Peer interface + Close func() error + Receive func() <-chan Message + func NewWebsocketPeer(serialization Serialization, url string, tlscfg *tls.Config, dial DialFunc) (Peer, error) + type Publish struct + Arguments []interface{} + ArgumentsKw map[string]interface{} + Options map[string]interface{} + Request ID + Topic URI + func (msg *Publish) MessageType() MessageType + type Published struct + Publication ID + Request ID + func (msg *Published) MessageType() MessageType + type RPCError struct + ErrorMessage *Error + Procedure string + func (rpc RPCError) Error() string + type Realm struct + AuthTimeout time.Duration + Authenticators map[string]Authenticator + Authorizer Authorizer + Broker Broker + CRAuthenticators map[string]CRAuthenticator + Dealer Dealer + Interceptor Interceptor + URI URI + func (r Realm) Close() + type RealmExistsError string + func (e RealmExistsError) Error() string + type Register struct + Options map[string]interface{} + Procedure URI + Request ID + func (msg *Register) MessageType() MessageType + type Registered struct + Registration ID + Request ID + func (msg *Registered) MessageType() MessageType + type Result struct + Arguments []interface{} + ArgumentsKw map[string]interface{} + Details map[string]interface{} + Request ID + func (msg *Result) MessageType() MessageType + type Router interface + Accept func(Peer) error + AddSessionCloseCallback func(func(uint, string)) + AddSessionOpenCallback func(func(uint, string)) + Close func() error + GetLocalPeer func(URI, map[string]interface{}) (Peer, error) + RegisterRealm func(URI, Realm) error + func NewDefaultRouter() Router + type Sender interface + Send func(Message) error + type Serialization int + const JSON + const MSGPACK + type Serializer interface + Deserialize func([]byte) (Message, error) + Serialize func(Message) ([]byte, error) + type Session struct + Details map[string]interface{} + Id ID + func (s *Session) NextRequestId() ID + func (s Session) String() string + type Subscribe struct + Options map[string]interface{} + Request ID + Topic URI + func (msg *Subscribe) MessageType() MessageType + type Subscribed struct + Request ID + Subscription ID + func (msg *Subscribed) MessageType() MessageType + type URI string + type Unregister struct + Registration ID + Request ID + func (msg *Unregister) MessageType() MessageType + type Unregistered struct + Request ID + func (msg *Unregistered) MessageType() MessageType + type Unsubscribe struct + Request ID + Subscription ID + func (msg *Unsubscribe) MessageType() MessageType + type Unsubscribed struct + Request ID + func (msg *Unsubscribed) MessageType() MessageType + type WebsocketServer struct + BinarySerializer Serializer + TextSerializer Serializer + Upgrader *websocket.Upgrader + func NewBasicWebsocketServer(uri string) *WebsocketServer + func NewWebsocketServer(realms map[string]Realm) (*WebsocketServer, error) + func (s *WebsocketServer) GetLocalClient(realm string, details map[string]interface{}) (*Client, error) + func (s *WebsocketServer) RegisterProtocol(proto string, payloadType int, serializer Serializer) error + func (s *WebsocketServer) ServeHTTP(w http.ResponseWriter, r *http.Request) + type Welcome struct + Details map[string]interface{} + Id ID + func (msg *Welcome) MessageType() MessageType + type Yield struct + Arguments []interface{} + ArgumentsKw map[string]interface{} + Options map[string]interface{} + Request ID + func (msg *Yield) MessageType() MessageType