http

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2018 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WildcardNamespace is the namespace used as wildcard. It is used by listeners to filter callbacks.
	WildcardNamespace = "*"
	ProtobufProtocol  = "protobuf"
	JsonProtocol      = "json"
)

Variables

View Source
var DefaultRequestTimeout = 10 * time.Second

DefaultRequestTimeout default timeout used for Request/Reply JSON message.

View Source
var (
	// ErrWrongCredentials error wrong credentials
	ErrWrongCredentials = errors.New("Wrong credentials")
)

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 AuthenticationOpts

type AuthenticationOpts struct {
	Username string
	Password string
}

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

OnMessage is called when a message is received.

type ExtraAsset added in v0.16.0

type ExtraAsset struct {
	Filename string
	Ext      string
	Content  []byte
}

type KeystoneAuthenticationBackend

type KeystoneAuthenticationBackend struct {
	AuthURL string
	Tenant  string
	Domain  string
}

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 (*KeystoneAuthenticationBackend) Wrap

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 PathPrefix

type PathPrefix string

type RestClient

type RestClient struct {
	// contains filtered or unexported fields
}

func NewRestClient

func NewRestClient(url *url.URL, authOptions *AuthenticationOpts) (*RestClient, error)

func (*RestClient) Request

func (c *RestClient) Request(method, path string, body io.Reader, header http.Header) (*http.Response, error)

type Route

type Route struct {
	Name        string
	Method      string
	Path        interface{}
	HandlerFunc auth.AuthenticatedHandlerFunc
}

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

func (s *Server) HandleFunc(path string, f auth.AuthenticatedHandlerFunc)

func (*Server) Listen added in v0.16.0

func (s *Server) Listen() error

func (*Server) ListenAndServe

func (s *Server) ListenAndServe()

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes(routes []Route)

func (*Server) Serve added in v0.16.0

func (s *Server) Serve()

func (*Server) Stop

func (s *Server) Stop()

type User added in v0.9.0

type User struct {
	ID   string `mapstructure:"id"`
	Name string `mapstructure:"name"`
}

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

func (c *WSConn) GetAddrPort() (string, int)

GetAddrPort returns the address and the port of the remote end.

func (*WSConn) GetClientProtocol added in v0.18.0

func (c *WSConn) GetClientProtocol() string

GetClientProtocol returns the websocket protocol.

func (*WSConn) GetHeaders added in v0.16.0

func (c *WSConn) GetHeaders() http.Header

GetHeaders returns the client HTTP headers.

func (*WSConn) GetHost added in v0.16.0

func (c *WSConn) GetHost() string

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

func (c *WSConn) GetURL() *url.URL

GetURL returns the URL of the connection

func (*WSConn) IsConnected added in v0.16.0

func (c *WSConn) IsConnected() bool

IsConnected returns the connection status.

func (*WSConn) SendMessage added in v0.16.0

func (c *WSConn) SendMessage(m WSMessage) error

SendMessage adds a message to sending queue.

func (*WSConn) SendRaw added in v0.16.0

func (c *WSConn) SendRaw(b []byte) error

SendRaw adds raw bytes 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

type WSIncomerHandler func(*websocket.Conn, *auth.AuthenticatedRequest) WSSpeaker

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

type WSMessage interface {
	Bytes(protocol string) []byte
}

WSMessage is the interface of a message to send over the wire

type WSPool added in v0.16.0

type WSPool struct {
	common.RWMutex
	// contains filtered or unexported fields
}

WSPool is a connection container. It embed a list of WSSpeaker.

func (*WSPool) AddClient added in v0.16.0

func (s *WSPool) AddClient(c WSSpeaker) error

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

func (s *WSPool) BroadcastMessage(m WSMessage)

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

func (s *WSPool) GetName() string

GetName returns the name of the pool

func (*WSPool) GetSpeakerByHost added in v0.16.0

func (s *WSPool) GetSpeakerByHost(host string) WSSpeaker

GetSpeakerByHost returns the WSSpeaker for the given host.

func (*WSPool) GetSpeakers added in v0.16.0

func (s *WSPool) GetSpeakers() (speakers []WSSpeaker)

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

func (s *WSPool) OnConnected(c WSSpeaker)

OnConnected forwards the OnConnected event to event listeners of the pool.

func (*WSPool) OnDisconnected added in v0.16.0

func (s *WSPool) OnDisconnected(c WSSpeaker)

OnDisconnected forwards the OnConnected event to event listeners of the pool.

func (*WSPool) OnMessage added in v0.16.0

func (s *WSPool) OnMessage(c WSSpeaker, m WSMessage)

OnMessage forwards the OnMessage event to event listeners of the pool.

func (*WSPool) PickConnectedSpeaker added in v0.16.0

func (s *WSPool) PickConnectedSpeaker() WSSpeaker

PickConnectedSpeaker returns randomly a connected WSSpeaker

func (*WSPool) QueueBroadcastMessage added in v0.16.0

func (s *WSPool) QueueBroadcastMessage(m WSMessage)

QueueBroadcastMessage enqueues a broadcast message.

func (*WSPool) RemoveClient added in v0.16.0

func (s *WSPool) RemoveClient(c WSSpeaker)

func (*WSPool) Run added in v0.16.0

func (s *WSPool) Run()

Run starts the pool.

func (*WSPool) SendMessageTo added in v0.16.0

func (s *WSPool) SendMessageTo(m WSMessage, host string) error

SendMessageTo sends message to WSSpeaker for the given host.

func (*WSPool) Start added in v0.16.0

func (s *WSPool) Start()

Start starts the pool in a goroutine.

func (*WSPool) Stop added in v0.16.0

func (s *WSPool) Stop()

Stop stops the pool and wait until stopped.

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

type WSServer struct {
	common.RWMutex
	// contains filtered or unexported fields
}

WSServer implements a websocket server. It owns a WSPool of incoming WSSpeakers.

func NewWSServer

func NewWSServer(server *Server, endpoint string) *WSServer

NewWSServer returns a new WSServer.

func (WSServer) AddClient added in v0.16.0

func (s WSServer) AddClient(c WSSpeaker) error

AddClient adds the given WSSpeaker to the wsIncomerPool.

func (WSServer) OnDisconnected added in v0.16.0

func (s WSServer) OnDisconnected(c WSSpeaker)

OnDisconnected forwards the OnConnected event to event listeners of the pool.

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

func (s WSStructServer) AddClient(c WSSpeaker) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL