Documentation
¶
Index ¶
- Constants
- Variables
- type AuthenticationBackend
- type AuthenticationClient
- type AuthenticationOpts
- type BasicAuthenticationBackend
- type ConnectionType
- type CrudClient
- func (c *CrudClient) Create(resource string, value interface{}) error
- func (c *CrudClient) Delete(resource string, id string) error
- func (c *CrudClient) Get(resource string, id string, value interface{}) error
- func (c *CrudClient) List(resource string, values interface{}) error
- func (c *CrudClient) Update(resource string, id string, value interface{}) error
- type DefaultWSSpeakerEventHandler
- type ExtraAsset
- type KeystoneAuthenticationBackend
- type NoAuthenticationBackend
- type PathPrefix
- type RestClient
- type Route
- type Server
- type User
- type WSClient
- type WSClientPool
- type WSConn
- func (c *WSConn) AddEventHandler(h WSSpeakerEventHandler)
- func (c *WSConn) Connect()
- func (c *WSConn) Disconnect()
- func (c *WSConn) GetAddrPort() (string, int)
- func (c *WSConn) GetClientProtocol() string
- func (c *WSConn) GetHeaders() http.Header
- func (c *WSConn) GetHost() string
- func (c *WSConn) GetServiceType() common.ServiceType
- func (c *WSConn) GetStatus() WSConnStatus
- func (c *WSConn) GetURL() *url.URL
- func (c *WSConn) IsConnected() bool
- func (c *WSConn) SendMessage(m WSMessage) error
- func (c *WSConn) SendRaw(b []byte) error
- type WSConnState
- type WSConnStatus
- type WSIncomerHandler
- type WSMasterElection
- type WSMasterEventHandler
- type WSMessage
- type WSPool
- func (s *WSPool) AddClient(c WSSpeaker) error
- func (s *WSPool) AddEventHandler(h WSSpeakerEventHandler)
- func (s *WSPool) BroadcastMessage(m WSMessage)
- func (s *WSPool) DisconnectAll()
- func (s *WSPool) GetName() string
- func (s *WSPool) GetSpeakerByHost(host string) WSSpeaker
- func (s *WSPool) GetSpeakers() (speakers []WSSpeaker)
- func (s *WSPool) GetSpeakersByType(serviceType common.ServiceType) (speakers []WSSpeaker)
- func (s *WSPool) GetStatus() map[string]WSConnStatus
- func (s *WSPool) OnConnected(c WSSpeaker)
- func (s *WSPool) OnDisconnected(c WSSpeaker)
- func (s *WSPool) OnMessage(c WSSpeaker, m WSMessage)
- func (s *WSPool) PickConnectedSpeaker() WSSpeaker
- func (s *WSPool) QueueBroadcastMessage(m WSMessage)
- func (s *WSPool) RemoveClient(c WSSpeaker)
- func (s *WSPool) Run()
- func (s *WSPool) SendMessageTo(m WSMessage, host string) error
- func (s *WSPool) Start()
- func (s *WSPool) Stop()
- type WSRawMessage
- type WSServer
- type WSSpeaker
- type WSSpeakerEventHandler
- type WSSpeakerPool
- type WSSpeakerStructMessageDispatcher
- type WSSpeakerStructMessageHandler
- type WSStructClientPool
- func (a *WSStructClientPool) AddClient(c WSSpeaker) error
- func (d WSStructClientPool) AddStructMessageHandler(h WSSpeakerStructMessageHandler, namespaces []string)
- func (d WSStructClientPool) AddStructSpeaker(c *WSStructSpeaker)
- func (s *WSStructClientPool) Request(host string, request *WSStructMessage, timeout time.Duration) (*WSStructMessage, error)
- type WSStructMessage
- func (g WSStructMessage) Bytes(protocol string) []byte
- func (g *WSStructMessage) Debug() string
- func (g *WSStructMessage) DecodeObj(obj interface{}) error
- func (g *WSStructMessage) Reply(v interface{}, kind string, status int) *WSStructMessage
- func (g *WSStructMessage) UnmarshalObj(obj interface{}) error
- type WSStructMessageJSON
- type WSStructServer
- func (s WSStructServer) AddClient(c WSSpeaker) error
- func (d WSStructServer) AddStructMessageHandler(h WSSpeakerStructMessageHandler, namespaces []string)
- func (d WSStructServer) AddStructSpeaker(c *WSStructSpeaker)
- func (s *WSStructServer) OnConnected(c WSSpeaker)
- func (s *WSStructServer) OnDisconnected(c WSSpeaker)
- func (s *WSStructServer) OnMessage(c WSSpeaker, m WSMessage)
- func (s *WSStructServer) Request(host string, request *WSStructMessage, timeout time.Duration) (*WSStructMessage, error)
- type WSStructSpeaker
- func (a WSStructSpeaker) AddStructMessageHandler(h WSSpeakerStructMessageHandler, namespaces []string)
- func (p WSStructSpeaker) OnConnected(c WSSpeaker)
- func (p WSStructSpeaker) OnDisconnected(c WSSpeaker)
- func (s *WSStructSpeaker) OnMessage(c WSSpeaker, m WSMessage)
- func (s *WSStructSpeaker) Request(m *WSStructMessage, timeout time.Duration) (*WSStructMessage, error)
- func (s *WSStructSpeaker) Send(m WSMessage)
- type WSStructSpeakerPool
Constants ¶
const ( // WildcardNamespace is the namespace used as wildcard. It is used by listeners to filter callbacks. WildcardNamespace = "*" ProtobufProtocol = "protobuf" JsonProtocol = "json" )
Variables ¶
DefaultRequestTimeout default timeout used for Request/Reply JSON message.
Functions ¶
This section is empty.
Types ¶
type AuthenticationBackend ¶
type AuthenticationBackend interface {
Authenticate(username string, password string) (string, error)
Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
}
func NewAuthenticationBackendFromConfig ¶
func NewAuthenticationBackendFromConfig() (AuthenticationBackend, error)
type AuthenticationClient ¶
type AuthenticationClient struct {
Url *url.URL
AuthToken string
// contains filtered or unexported fields
}
func NewAuthenticationClient ¶
func NewAuthenticationClient(url *url.URL, authOptions *AuthenticationOpts) *AuthenticationClient
func (*AuthenticationClient) AuthCookies ¶ added in v0.16.0
func (c *AuthenticationClient) AuthCookies() []*http.Cookie
func (*AuthenticationClient) Authenticate ¶
func (c *AuthenticationClient) Authenticate() error
func (*AuthenticationClient) Authenticated ¶
func (c *AuthenticationClient) Authenticated() bool
func (*AuthenticationClient) Cookie ¶
func (c *AuthenticationClient) Cookie() *http.Cookie
type BasicAuthenticationBackend ¶
type BasicAuthenticationBackend struct {
*auth.BasicAuth
}
func NewBasicAuthenticationBackend ¶
func NewBasicAuthenticationBackend(file string) (*BasicAuthenticationBackend, error)
func NewBasicAuthenticationBackendFromConfig ¶
func NewBasicAuthenticationBackendFromConfig() (*BasicAuthenticationBackend, error)
func (*BasicAuthenticationBackend) Authenticate ¶
func (b *BasicAuthenticationBackend) Authenticate(username string, password string) (string, error)
func (*BasicAuthenticationBackend) Wrap ¶
func (b *BasicAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
type ConnectionType ¶ added in v0.16.0
type ConnectionType int
const ( // TCP connection TCP ConnectionType = 1 + iota // TLS secure connection TLS // ExtraAssetPrefix is used for extra assets ExtraAssetPrefix = "/extra-statics" )
type CrudClient ¶
type CrudClient struct {
RestClient
}
func NewCrudClient ¶
func NewCrudClient(url *url.URL, authOpts *AuthenticationOpts) (*CrudClient, error)
func (*CrudClient) Create ¶
func (c *CrudClient) Create(resource string, value interface{}) error
func (*CrudClient) Delete ¶
func (c *CrudClient) Delete(resource string, id string) error
func (*CrudClient) Get ¶
func (c *CrudClient) Get(resource string, id string, value interface{}) error
func (*CrudClient) List ¶
func (c *CrudClient) List(resource string, values interface{}) error
func (*CrudClient) Update ¶
func (c *CrudClient) Update(resource string, id string, value interface{}) error
type DefaultWSSpeakerEventHandler ¶ added in v0.16.0
type DefaultWSSpeakerEventHandler struct {
}
DefaultWSSpeakerEventHandler implements stubs for the wsIncomingClientEventHandler interface
func (*DefaultWSSpeakerEventHandler) OnConnected ¶ added in v0.16.0
func (d *DefaultWSSpeakerEventHandler) OnConnected(c WSSpeaker)
OnConnected is called when the connection is established.
func (*DefaultWSSpeakerEventHandler) OnDisconnected ¶ added in v0.16.0
func (d *DefaultWSSpeakerEventHandler) OnDisconnected(c WSSpeaker)
OnDisconnected is called when the connection is closed or lost.
func (*DefaultWSSpeakerEventHandler) OnMessage ¶ added in v0.16.0
func (d *DefaultWSSpeakerEventHandler) OnMessage(c WSSpeaker, m WSMessage)
OnMessage is called when a message is received.
type ExtraAsset ¶ added in v0.16.0
type KeystoneAuthenticationBackend ¶
func NewKeystoneAuthenticationBackendFromConfig ¶
func NewKeystoneAuthenticationBackendFromConfig() *KeystoneAuthenticationBackend
func NewKeystoneBackend ¶
func NewKeystoneBackend(authURL string, tenant string, domain string) *KeystoneAuthenticationBackend
func (*KeystoneAuthenticationBackend) Authenticate ¶
func (b *KeystoneAuthenticationBackend) Authenticate(username string, password string) (string, error)
func (*KeystoneAuthenticationBackend) CheckUser ¶
func (b *KeystoneAuthenticationBackend) CheckUser(r *http.Request) (string, error)
func (*KeystoneAuthenticationBackend) Wrap ¶
func (b *KeystoneAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
type NoAuthenticationBackend ¶
type NoAuthenticationBackend struct {
}
func NewNoAuthenticationBackend ¶
func NewNoAuthenticationBackend() *NoAuthenticationBackend
func (*NoAuthenticationBackend) AuthType ¶ added in v0.18.0
func (h *NoAuthenticationBackend) AuthType() string
func (*NoAuthenticationBackend) Authenticate ¶
func (h *NoAuthenticationBackend) Authenticate(username string, password string) (string, error)
func (*NoAuthenticationBackend) Wrap ¶
func (h *NoAuthenticationBackend) Wrap(wrapped auth.AuthenticatedHandlerFunc) http.HandlerFunc
type RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
func NewRestClient ¶
func NewRestClient(url *url.URL, authOptions *AuthenticationOpts) (*RestClient, error)
type Route ¶
type Server ¶
type Server struct {
http.Server
Host string
ServiceType common.ServiceType
Router *mux.Router
Addr string
Port int
Auth AuthenticationBackend
CnxType ConnectionType
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(host string, serviceType common.ServiceType, addr string, port int, auth AuthenticationBackend, assetsFolder string) *Server
func NewServerFromConfig ¶
func NewServerFromConfig(serviceType common.ServiceType) (*Server, error)
func (*Server) HandleFunc ¶
type User ¶ added in v0.9.0
type WSClient ¶
type WSClient struct {
*WSConn
Path string
AuthClient *AuthenticationClient
}
WSClient is a outgoint client meaning a client connected to a remote websocket server. It embeds a WSConn.
func NewWSClient ¶ added in v0.16.0
func NewWSClient(host string, clientType common.ServiceType, url *url.URL, authClient *AuthenticationClient, headers http.Header, queueSize int) *WSClient
NewWSClient returns a WSClient with a new connection.
func NewWSClientFromConfig ¶ added in v0.16.0
func NewWSClientFromConfig(clientType common.ServiceType, url *url.URL, authClient *AuthenticationClient, headers http.Header) *WSClient
NewWSClientFromConfig creates a WSClient based on the configuration
func (*WSClient) Connect ¶ added in v0.16.0
func (c *WSClient) Connect()
Connect to the server - and reconnect if necessary
func (*WSClient) UpgradeToWSStructSpeaker ¶ added in v0.18.0
func (c *WSClient) UpgradeToWSStructSpeaker() *WSStructSpeaker
type WSClientPool ¶ added in v0.16.0
type WSClientPool struct {
*WSPool
}
WSClientPool is a pool of out going WSSpeaker meaning connection to a remote WSServer.
func NewWSClientPool ¶ added in v0.16.0
func NewWSClientPool(name string) *WSClientPool
NewWSClientPool returns a new WSClientPool meaning a pool of outgoing WSClient.
func (*WSClientPool) ConnectAll ¶ added in v0.16.0
func (s *WSClientPool) ConnectAll()
ConnectAll calls connect to all the wSSpeakers of the pool.
type WSConn ¶ added in v0.16.0
type WSConn struct {
common.RWMutex
WSConnStatus
// contains filtered or unexported fields
}
WSConn is the connection object of a WSSpeaker
func (*WSConn) AddEventHandler ¶ added in v0.16.0
func (c *WSConn) AddEventHandler(h WSSpeakerEventHandler)
AddEventHandler registers a new event handler
func (*WSConn) Connect ¶ added in v0.16.0
func (c *WSConn) Connect()
Connect default implementation doing nothing as for incoming connection it is not used.
func (*WSConn) Disconnect ¶ added in v0.16.0
func (c *WSConn) Disconnect()
Disconnect the WSSpeakers without waiting for termination.
func (*WSConn) GetAddrPort ¶ added in v0.16.0
GetAddrPort returns the address and the port of the remote end.
func (*WSConn) GetClientProtocol ¶ added in v0.18.0
GetClientProtocol returns the websocket protocol.
func (*WSConn) GetHeaders ¶ added in v0.16.0
GetHeaders returns the client HTTP headers.
func (*WSConn) GetHost ¶ added in v0.16.0
GetHost returns the hostname/host-id of the connection.
func (*WSConn) GetServiceType ¶ added in v0.16.0
func (c *WSConn) GetServiceType() common.ServiceType
GetServiceType returns the client type.
func (*WSConn) GetStatus ¶ added in v0.16.0
func (c *WSConn) GetStatus() WSConnStatus
GetStatus returns the status of a WebSocket connection
func (*WSConn) GetURL ¶ added in v0.16.0
GetURL returns the URL of the connection
func (*WSConn) IsConnected ¶ added in v0.16.0
IsConnected returns the connection status.
func (*WSConn) SendMessage ¶ added in v0.16.0
SendMessage adds a message to sending queue.
type WSConnState ¶ added in v0.16.0
type WSConnState int32
WSConnState describes the connection state
func (*WSConnState) MarshalJSON ¶ added in v0.16.0
func (s *WSConnState) MarshalJSON() ([]byte, error)
func (*WSConnState) UnmarshalJSON ¶ added in v0.16.0
func (s *WSConnState) UnmarshalJSON(b []byte) error
UnmarshalJSON deserialize a connection state
type WSConnStatus ¶ added in v0.16.0
type WSConnStatus struct {
ServiceType common.ServiceType
ClientProtocol string
Addr string
Port int
Host string `json:"-"`
State *WSConnState `json:"IsConnected"`
Url *url.URL `json:"-"`
ConnectTime time.Time
// contains filtered or unexported fields
}
WSConnStatus describes the status of a WebSocket connection
type WSIncomerHandler ¶ added in v0.16.0
WSIncomerHandler incoming client handler interface.
type WSMasterElection ¶ added in v0.16.0
type WSMasterElection struct {
common.RWMutex
DefaultWSSpeakerEventHandler
// contains filtered or unexported fields
}
WSMasterElection provides a mechanism based on etcd to elect a master from a WSSpeakerPool.
func NewWSMasterElection ¶ added in v0.16.0
func NewWSMasterElection(pool WSSpeakerPool) *WSMasterElection
NewWSMasterElection returns a new WSMasterElection.
func (*WSMasterElection) AddEventHandler ¶ added in v0.16.0
func (a *WSMasterElection) AddEventHandler(eventHandler WSMasterEventHandler)
AddEventHandler a new WSMasterEventHandler event handler.
func (*WSMasterElection) GetMaster ¶ added in v0.16.0
func (a *WSMasterElection) GetMaster() WSSpeaker
GetMaster returns the current master.
func (*WSMasterElection) OnConnected ¶ added in v0.16.0
func (a *WSMasterElection) OnConnected(c WSSpeaker)
OnConnected is triggered when a new WSSpeaker get connected. If no master was elected this WSSpeaker will be choosen as master.
func (*WSMasterElection) OnDisconnected ¶ added in v0.16.0
func (a *WSMasterElection) OnDisconnected(c WSSpeaker)
OnDisconnected is triggered when a new WSSpeaker get disconnected. If it was the master a new election is triggered.
func (*WSMasterElection) SendMessageToMaster ¶ added in v0.16.0
func (a *WSMasterElection) SendMessageToMaster(m WSMessage)
SendMessageToMaster sends a message to the master.
type WSMasterEventHandler ¶ added in v0.16.0
type WSMasterEventHandler interface {
OnNewMaster(c WSSpeaker)
}
WSMasterEventHandler is the interface to be implemented by master election listeners.
type WSMessage ¶
WSMessage is the interface of a message to send over the wire
type WSPool ¶ added in v0.16.0
WSPool is a connection container. It embed a list of WSSpeaker.
func (*WSPool) AddClient ¶ added in v0.16.0
AddClient adds the given WSSpeaker to the pool.
func (*WSPool) AddEventHandler ¶ added in v0.16.0
func (s *WSPool) AddEventHandler(h WSSpeakerEventHandler)
AddEventHandler registers a new event handler.
func (*WSPool) BroadcastMessage ¶ added in v0.16.0
BroadcastMessage broadcasts the given message.
func (*WSPool) DisconnectAll ¶ added in v0.16.0
func (s *WSPool) DisconnectAll()
DisconnectAll disconnects all the WSSpeaker
func (*WSPool) GetName ¶ added in v0.16.0
GetName returns the name of the pool
func (*WSPool) GetSpeakerByHost ¶ added in v0.16.0
GetSpeakerByHost returns the WSSpeaker for the given host.
func (*WSPool) GetSpeakers ¶ added in v0.16.0
GetSpeakers returns the WSSpeakers of the pool.
func (*WSPool) GetSpeakersByType ¶ added in v0.16.0
func (s *WSPool) GetSpeakersByType(serviceType common.ServiceType) (speakers []WSSpeaker)
GetSpeakersByType returns WSSpeakers matching the given type.
func (*WSPool) GetStatus ¶ added in v0.16.0
func (s *WSPool) GetStatus() map[string]WSConnStatus
GetStatus returns the states of the WebSocket clients
func (*WSPool) OnConnected ¶ added in v0.16.0
OnConnected forwards the OnConnected event to event listeners of the pool.
func (*WSPool) OnDisconnected ¶ added in v0.16.0
OnDisconnected forwards the OnConnected event to event listeners of the pool.
func (*WSPool) OnMessage ¶ added in v0.16.0
OnMessage forwards the OnMessage event to event listeners of the pool.
func (*WSPool) PickConnectedSpeaker ¶ added in v0.16.0
PickConnectedSpeaker returns randomly a connected WSSpeaker
func (*WSPool) QueueBroadcastMessage ¶ added in v0.16.0
QueueBroadcastMessage enqueues a broadcast message.
func (*WSPool) SendMessageTo ¶ added in v0.16.0
SendMessageTo sends message to WSSpeaker for the given host.
type WSRawMessage ¶ added in v0.16.0
type WSRawMessage []byte
WSRawMessage represents a raw message (array of bytes)
func (WSRawMessage) Bytes ¶ added in v0.16.0
func (m WSRawMessage) Bytes(protocol string) []byte
Bytes returns the string representation of the raw message
type WSServer ¶
WSServer implements a websocket server. It owns a WSPool of incoming WSSpeakers.
func NewWSServer ¶
NewWSServer returns a new WSServer.
func (WSServer) AddClient ¶ added in v0.16.0
AddClient adds the given WSSpeaker to the wsIncomerPool.
type WSSpeaker ¶ added in v0.16.0
type WSSpeaker interface {
GetStatus() WSConnStatus
GetHost() string
GetAddrPort() (string, int)
GetServiceType() common.ServiceType
GetClientProtocol() string
GetHeaders() http.Header
GetURL() *url.URL
IsConnected() bool
SendMessage(m WSMessage) error
Connect()
Disconnect()
AddEventHandler(WSSpeakerEventHandler)
}
WSSpeaker is the interface for a websocket speaking client. It is used for outgoing or incoming connections.
type WSSpeakerEventHandler ¶ added in v0.16.0
type WSSpeakerEventHandler interface {
OnMessage(c WSSpeaker, m WSMessage)
OnConnected(c WSSpeaker)
OnDisconnected(c WSSpeaker)
}
WSSpeakerEventHandler is the interface to be implement by the client events listeners.
type WSSpeakerPool ¶ added in v0.16.0
type WSSpeakerPool interface {
AddClient(c WSSpeaker) error
RemoveClient(c WSSpeaker)
AddEventHandler(h WSSpeakerEventHandler)
GetSpeakers() []WSSpeaker
PickConnectedSpeaker() WSSpeaker
BroadcastMessage(m WSMessage)
SendMessageTo(m WSMessage, host string) error
QueueBroadcastMessage(m WSMessage)
}
WSSpeakerPool is the interface that WSSpeaker pools have to implement.
type WSSpeakerStructMessageDispatcher ¶ added in v0.18.0
type WSSpeakerStructMessageDispatcher interface {
AddStructMessageHandler(h WSSpeakerStructMessageHandler, namespaces []string)
}
WSSpeakerStructMessageDispatcher interface is used to dispatch OnWSStructMessage events.
type WSSpeakerStructMessageHandler ¶ added in v0.18.0
type WSSpeakerStructMessageHandler interface {
OnWSStructMessage(c WSSpeaker, m *WSStructMessage)
}
WSSpeakerStructMessageHandler interface used to receive Struct messages.
type WSStructClientPool ¶ added in v0.18.0
type WSStructClientPool struct {
*WSClientPool
// contains filtered or unexported fields
}
WSStructClientPool is a WSClientPool able to send WSStructMessage.
func NewWSStructClientPool ¶ added in v0.18.0
func NewWSStructClientPool(name string) *WSStructClientPool
NewWSStructClientPool returns a new WSStructClientPool.
func (*WSStructClientPool) AddClient ¶ added in v0.18.0
func (a *WSStructClientPool) AddClient(c WSSpeaker) error
AddClient adds a WSClient to the pool.
func (WSStructClientPool) AddStructMessageHandler ¶ added in v0.18.0
func (d WSStructClientPool) AddStructMessageHandler(h WSSpeakerStructMessageHandler, namespaces []string)
AddStructMessageHandler adds a new listener for Struct messages.
func (WSStructClientPool) AddStructSpeaker ¶ added in v0.18.0
func (d WSStructClientPool) AddStructSpeaker(c *WSStructSpeaker)
func (*WSStructClientPool) Request ¶ added in v0.18.0
func (s *WSStructClientPool) Request(host string, request *WSStructMessage, timeout time.Duration) (*WSStructMessage, error)
Request sends a Request Struct message to the WSSpeaker of the given host.
type WSStructMessage ¶ added in v0.18.0
type WSStructMessage struct {
Protocol string
Namespace string
Type string
UUID string
Status int64
JsonObj *json.RawMessage
ProtobufObj []byte
// contains filtered or unexported fields
}
func NewWSStructMessage ¶ added in v0.18.0
func NewWSStructMessage(ns string, tp string, v interface{}, uuids ...string) *WSStructMessage
NewWSStructMessage creates a new WSStructMessage with the given namespace, type, value and optionally the UUID.
func (WSStructMessage) Bytes ¶ added in v0.18.0
func (g WSStructMessage) Bytes(protocol string) []byte
Bytes see Marshal
func (*WSStructMessage) Debug ¶ added in v0.18.0
func (g *WSStructMessage) Debug() string
Debug representation of the struct WSStructMessage
func (*WSStructMessage) DecodeObj ¶ added in v0.18.0
func (g *WSStructMessage) DecodeObj(obj interface{}) error
func (*WSStructMessage) Reply ¶ added in v0.18.0
func (g *WSStructMessage) Reply(v interface{}, kind string, status int) *WSStructMessage
Reply returns a reply message with the given value, type and status. Basically it return a new WSStructMessage with the correct Namespace and UUID.
func (*WSStructMessage) UnmarshalObj ¶ added in v0.18.0
func (g *WSStructMessage) UnmarshalObj(obj interface{}) error
type WSStructMessageJSON ¶ added in v0.18.0
type WSStructMessageJSON struct {
Namespace string
Type string
UUID string
Status int64
Obj *json.RawMessage
}
func (*WSStructMessageJSON) Marshal ¶ added in v0.18.0
func (g *WSStructMessageJSON) Marshal() []byte
Marshal serializes the WSStructMessage into a JSON string.
type WSStructServer ¶ added in v0.18.0
type WSStructServer struct {
*WSServer
// contains filtered or unexported fields
}
WSStructServer is a WSServer able to handle WSStructSpeaker.
func NewWSStructServer ¶ added in v0.18.0
func NewWSStructServer(server *WSServer) *WSStructServer
NewWSStructServer returns a new WSStructServer
func (WSStructServer) AddClient ¶ added in v0.18.0
AddClient adds the given WSSpeaker to the wsIncomerPool.
func (WSStructServer) AddStructMessageHandler ¶ added in v0.18.0
func (d WSStructServer) AddStructMessageHandler(h WSSpeakerStructMessageHandler, namespaces []string)
AddStructMessageHandler adds a new listener for Struct messages.
func (WSStructServer) AddStructSpeaker ¶ added in v0.18.0
func (d WSStructServer) AddStructSpeaker(c *WSStructSpeaker)
func (*WSStructServer) OnConnected ¶ added in v0.18.0
func (s *WSStructServer) OnConnected(c WSSpeaker)
OnConnected websocket event.
func (*WSStructServer) OnDisconnected ¶ added in v0.18.0
func (s *WSStructServer) OnDisconnected(c WSSpeaker)
OnDisconnected removes the WSSpeaker from the incomer pool.
func (*WSStructServer) OnMessage ¶ added in v0.18.0
func (s *WSStructServer) OnMessage(c WSSpeaker, m WSMessage)
OnMessage websocket event.
func (*WSStructServer) Request ¶ added in v0.18.0
func (s *WSStructServer) Request(host string, request *WSStructMessage, timeout time.Duration) (*WSStructMessage, error)
Request sends a Request Struct message to the WSSpeaker of the given host.
type WSStructSpeaker ¶ added in v0.18.0
type WSStructSpeaker struct {
WSSpeaker
// contains filtered or unexported fields
}
WSStructSpeaker is a WSSpeaker able to handle Struct Message and Request/Reply calls.
func (WSStructSpeaker) AddStructMessageHandler ¶ added in v0.18.0
func (a WSStructSpeaker) AddStructMessageHandler(h WSSpeakerStructMessageHandler, namespaces []string)
AddStructMessageHandler adds a new listener for Struct messages.
func (WSStructSpeaker) OnConnected ¶ added in v0.18.0
func (p WSStructSpeaker) OnConnected(c WSSpeaker)
OnConnected is implemented here to avoid infinite loop since the default implemtation is triggering OnDisconnected too.
func (WSStructSpeaker) OnDisconnected ¶ added in v0.18.0
func (p WSStructSpeaker) OnDisconnected(c WSSpeaker)
OnDisconnected is implemented here to avoid infinite loop since the default implemtation is triggering OnDisconnected too.
func (*WSStructSpeaker) OnMessage ¶ added in v0.18.0
func (s *WSStructSpeaker) OnMessage(c WSSpeaker, m WSMessage)
OnMessage checks that the WSMessage comes from a WSStructSpeaker. It parses the Struct message and then dispatch the message to the proper listeners according to the namespace.
func (*WSStructSpeaker) Request ¶ added in v0.18.0
func (s *WSStructSpeaker) Request(m *WSStructMessage, timeout time.Duration) (*WSStructMessage, error)
Request sends a Struct message request waiting for a reply using the given timeout.
func (*WSStructSpeaker) Send ¶ added in v0.18.0
func (s *WSStructSpeaker) Send(m WSMessage)
Send sends a message according to the namespace.
type WSStructSpeakerPool ¶ added in v0.18.0
type WSStructSpeakerPool interface {
WSSpeakerPool
WSSpeakerStructMessageDispatcher
Request(host string, request *WSStructMessage, timeout time.Duration) (*WSStructMessage, error)
}
WSStructSpeakerPool is the interface of a pool of WSStructSpeakers.
Source Files
¶
- auth.go
- basic.go
- client.go
- keystone.go
- master.go
- noauth.go
- pool.go
- server.go
- tls.go
- wsclient.go
- wsmessage.go
- wsserver.go