http

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WilcardNamespace is the namespace used as wildcard. It is used by listeners to filter callbacks.
	WilcardNamespace = "*"
	BulkMsgType      = "BulkMessage"
)

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 added in v0.5.0

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.12.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

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.13.0

type DefaultWSSpeakerEventHandler struct {
}

DefaultWSSpeakerEventHandler implements stubs for the wsIncomingClientEventHandler interface

func (*DefaultWSSpeakerEventHandler) OnConnected added in v0.13.0

func (d *DefaultWSSpeakerEventHandler) OnConnected(c WSSpeaker)

OnConnected is called when the connection is established.

func (*DefaultWSSpeakerEventHandler) OnDisconnected added in v0.13.0

func (d *DefaultWSSpeakerEventHandler) OnDisconnected(c WSSpeaker)

OnDisconnected is called when the connection is closed or lost.

func (*DefaultWSSpeakerEventHandler) OnMessage added in v0.13.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) 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

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.13.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.13.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 WSBulkMessage added in v0.12.0

type WSBulkMessage []json.RawMessage

WSBulkMessage bulk of RawMessage.

type WSClient added in v0.5.0

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.13.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.13.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.13.0

func (c *WSClient) Connect()

Connect to the server - and reconnect if necessary

func (*WSClient) UpgradeToWSJSONSpeaker added in v0.16.0

func (c *WSClient) UpgradeToWSJSONSpeaker() *WSJSONSpeaker

type WSClientPool added in v0.13.0

type WSClientPool struct {
	*WSPool
}

WSClientPool is a pool of out going WSSpeaker meaning connection to a remote WSServer.

func NewWSClientPool added in v0.13.0

func NewWSClientPool(name string) *WSClientPool

NewWSClientPool returns a new WSClientPool meaning a pool of outgoing WSClient.

func (*WSClientPool) ConnectAll added in v0.13.0

func (s *WSClientPool) ConnectAll()

ConnectAll calls connect to all the wSSpeakers of the pool.

type WSConn added in v0.13.0

type WSConn struct {
	sync.RWMutex
	WSConnStatus
	// contains filtered or unexported fields
}

WSConn is the connection object of a WSSpeaker

func (*WSConn) AddEventHandler added in v0.13.0

func (c *WSConn) AddEventHandler(h WSSpeakerEventHandler)

AddEventHandler registers a new event handler

func (*WSConn) Connect added in v0.13.0

func (c *WSConn) Connect()

Connect default implementation doing nothing as for incoming connection it is not used.

func (*WSConn) Disconnect added in v0.13.0

func (c *WSConn) Disconnect()

Disconnect the WSSpeakers without waiting for termination.

func (*WSConn) GetAddrPort added in v0.13.0

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

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

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.13.0

func (c *WSConn) GetHost() string

GetHost returns the hostname/host-id of the connection.

func (*WSConn) GetServiceType added in v0.13.0

func (c *WSConn) GetServiceType() common.ServiceType

GetServiceType returns the client type.

func (*WSConn) GetStatus added in v0.13.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.13.0

func (c *WSConn) IsConnected() bool

IsConnected returns the connection status.

func (*WSConn) SendMessage added in v0.13.0

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

SendMessage adds a message to sending queue.

func (*WSConn) SendRaw added in v0.13.0

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

SendRaw adds raw bytes to sending queue.

type WSConnState added in v0.13.0

type WSConnState int32

WSConnState describes the connection state

func (*WSConnState) MarshalJSON added in v0.13.0

func (s *WSConnState) MarshalJSON() ([]byte, error)

func (*WSConnState) UnmarshalJSON added in v0.13.0

func (s *WSConnState) UnmarshalJSON(b []byte) error

UnmarshalJSON deserialize a connection state

type WSConnStatus added in v0.13.0

type WSConnStatus struct {
	ServiceType common.ServiceType
	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.13.0

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

WSIncomerHandler incoming client handler interface.

type WSJSONClientPool added in v0.13.0

type WSJSONClientPool struct {
	*WSClientPool
	// contains filtered or unexported fields
}

WSJSONClientPool is a WSClientPool able to send WSJSONMessage.

func NewWSJSONClientPool added in v0.13.0

func NewWSJSONClientPool(name string) *WSJSONClientPool

NewWSJSONClientPool returns a new WSJSONClientPool.

func (*WSJSONClientPool) AddClient added in v0.13.0

func (a *WSJSONClientPool) AddClient(c WSSpeaker) error

AddClient adds a WSClient to the pool.

func (WSJSONClientPool) AddJSONMessageHandler added in v0.13.0

func (d WSJSONClientPool) AddJSONMessageHandler(h WSSpeakerJSONMessageHandler, namespaces []string)

AddJSONMessageHandler adds a new listener for JSON messages.

func (WSJSONClientPool) AddJSONSpeaker added in v0.16.0

func (d WSJSONClientPool) AddJSONSpeaker(c *WSJSONSpeaker)

func (*WSJSONClientPool) Request added in v0.13.0

func (s *WSJSONClientPool) Request(host string, request *WSJSONMessage, timeout time.Duration) (*WSJSONMessage, error)

Request sends a Request JSON message to the WSSpeaker of the given host.

type WSJSONMessage added in v0.13.0

type WSJSONMessage struct {
	Namespace string
	Type      string
	UUID      string `json:",omitempty"`
	Obj       *json.RawMessage
	Status    int
	// contains filtered or unexported fields
}

WSJSONMessage is JSON based message on top of WSMessage. It implements to WSMessage interface and can be sent with via a WSSpeaker.

func NewWSJSONMessage added in v0.13.0

func NewWSJSONMessage(ns string, tp string, v interface{}, uuids ...string) *WSJSONMessage

NewWSJSONMessage creates a new WSJSONMessage with the given namespace, type, value and optionally the UUID.

func (WSJSONMessage) Bytes added in v0.13.0

func (g WSJSONMessage) Bytes() []byte

Bytes see Marshal

func (WSJSONMessage) Marshal added in v0.13.0

func (g WSJSONMessage) Marshal() []byte

Marshal serializes the WSJSONMessage into a JSON string.

func (*WSJSONMessage) Reply added in v0.13.0

func (g *WSJSONMessage) Reply(v interface{}, kind string, status int) *WSJSONMessage

Reply returns a reply message with the given value, type and status. Basically it return a new WSJSONMessage with the correct Namespace and UUID.

type WSJSONServer added in v0.13.0

type WSJSONServer struct {
	*WSServer
	// contains filtered or unexported fields
}

WSJSONServer is a WSServer able to handle WSJSONSpeaker.

func NewWSJSONServer added in v0.13.0

func NewWSJSONServer(server *WSServer) *WSJSONServer

NewWSJSONServer returns a new WSJSONServer

func (WSJSONServer) AddClient added in v0.16.0

func (s WSJSONServer) AddClient(c WSSpeaker) error

AddClient adds the given WSSpeaker to the wsIncomerPool.

func (WSJSONServer) AddJSONMessageHandler added in v0.13.0

func (d WSJSONServer) AddJSONMessageHandler(h WSSpeakerJSONMessageHandler, namespaces []string)

AddJSONMessageHandler adds a new listener for JSON messages.

func (WSJSONServer) AddJSONSpeaker added in v0.16.0

func (d WSJSONServer) AddJSONSpeaker(c *WSJSONSpeaker)

func (*WSJSONServer) OnConnected added in v0.13.0

func (s *WSJSONServer) OnConnected(c WSSpeaker)

OnConnected websocket event.

func (*WSJSONServer) OnDisconnected added in v0.13.0

func (s *WSJSONServer) OnDisconnected(c WSSpeaker)

OnDisconnected removes the WSSpeaker from the incomer pool.

func (*WSJSONServer) OnMessage added in v0.13.0

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

OnMessage websocket event.

func (*WSJSONServer) Request added in v0.13.0

func (s *WSJSONServer) Request(host string, request *WSJSONMessage, timeout time.Duration) (*WSJSONMessage, error)

Request sends a Request JSON message to the WSSpeaker of the given host.

type WSJSONSpeaker added in v0.13.0

type WSJSONSpeaker struct {
	WSSpeaker
	// contains filtered or unexported fields
}

WSJSONSpeaker is a WSSpeaker able to handle JSON Message and Request/Reply calls.

func (WSJSONSpeaker) AddJSONMessageHandler added in v0.13.0

func (a WSJSONSpeaker) AddJSONMessageHandler(h WSSpeakerJSONMessageHandler, namespaces []string)

AddJSONMessageHandler adds a new listener for JSON messages.

func (WSJSONSpeaker) OnConnected added in v0.13.0

func (p WSJSONSpeaker) OnConnected(c WSSpeaker)

OnConnected is implemented here to avoid infinite loop since the default implemtation is triggering OnDisconnected too.

func (WSJSONSpeaker) OnDisconnected added in v0.13.0

func (p WSJSONSpeaker) OnDisconnected(c WSSpeaker)

OnDisconnected is implemented here to avoid infinite loop since the default implemtation is triggering OnDisconnected too.

func (*WSJSONSpeaker) OnMessage added in v0.13.0

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

OnMessage checks that the WSMessage comes from a WSJSONSpeaker. It parses the JSON message and then dispatch the message to the proper listeners according to the namespace.

func (*WSJSONSpeaker) Request added in v0.13.0

func (s *WSJSONSpeaker) Request(m *WSJSONMessage, timeout time.Duration) (*WSJSONMessage, error)

Request sends a JSON message request waiting for a reply using the given timeout.

func (*WSJSONSpeaker) Send added in v0.13.0

func (s *WSJSONSpeaker) Send(m WSMessage)

Send sends a message according to the namespace.

type WSJSONSpeakerPool added in v0.13.0

type WSJSONSpeakerPool interface {
	WSSpeakerPool
	WSSpeakerJSONMessageDispatcher
	Request(host string, request *WSJSONMessage, timeout time.Duration) (*WSJSONMessage, error)
}

WSJSONSpeakerPool is the interface of a pool of WSJSONSpeakers.

type WSMasterElection added in v0.13.0

type WSMasterElection struct {
	sync.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.13.0

func NewWSMasterElection(pool WSSpeakerPool) *WSMasterElection

NewWSMasterElection returns a new WSMasterElection.

func (*WSMasterElection) AddEventHandler added in v0.13.0

func (a *WSMasterElection) AddEventHandler(eventHandler WSMasterEventHandler)

AddEventHandler a new WSMasterEventHandler event handler.

func (*WSMasterElection) GetMaster added in v0.13.0

func (a *WSMasterElection) GetMaster() WSSpeaker

GetMaster returns the current master.

func (*WSMasterElection) OnConnected added in v0.13.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.13.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.13.0

func (a *WSMasterElection) SendMessageToMaster(m WSMessage)

SendMessageToMaster sends a message to the master.

type WSMasterEventHandler added in v0.13.0

type WSMasterEventHandler interface {
	OnNewMaster(c WSSpeaker)
}

WSMasterEventHandler is the interface to be implemented by master election listeners.

type WSMessage added in v0.5.0

type WSMessage interface {
	Bytes() []byte
}

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

type WSPool added in v0.13.0

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

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

func (*WSPool) AddClient added in v0.13.0

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

AddClient adds the given WSSpeaker to the pool.

func (*WSPool) AddEventHandler added in v0.13.0

func (s *WSPool) AddEventHandler(h WSSpeakerEventHandler)

AddEventHandler registers a new event handler.

func (*WSPool) BroadcastMessage added in v0.13.0

func (s *WSPool) BroadcastMessage(m WSMessage)

BroadcastMessage broadcasts the given message.

func (*WSPool) DisconnectAll added in v0.13.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.13.0

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

GetSpeakerByHost returns the WSSpeaker for the given host.

func (*WSPool) GetSpeakers added in v0.13.0

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

GetSpeakers returns the WSSpeakers of the pool.

func (*WSPool) GetSpeakersByType added in v0.13.0

func (s *WSPool) GetSpeakersByType(serviceType common.ServiceType) (speakers []WSSpeaker)

GetSpeakersByType returns WSSpeakers matching the given type.

func (*WSPool) GetStatus added in v0.13.0

func (s *WSPool) GetStatus() map[string]WSConnStatus

GetStatus returns the states of the WebSocket clients

func (*WSPool) OnConnected added in v0.13.0

func (s *WSPool) OnConnected(c WSSpeaker)

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

func (*WSPool) OnDisconnected added in v0.13.0

func (s *WSPool) OnDisconnected(c WSSpeaker)

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

func (*WSPool) OnMessage added in v0.13.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.13.0

func (s *WSPool) PickConnectedSpeaker() WSSpeaker

PickConnectedSpeaker returns randomly a connected WSSpeaker

func (*WSPool) QueueBroadcastMessage added in v0.13.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.13.0

func (s *WSPool) Run()

Run starts the pool.

func (*WSPool) SendMessageTo added in v0.13.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.13.0

func (s *WSPool) Start()

Start starts the pool in a goroutine.

func (*WSPool) Stop added in v0.13.0

func (s *WSPool) Stop()

Stop stops the pool and wait until stopped.

type WSRawMessage added in v0.13.0

type WSRawMessage []byte

WSRawMessage represents a raw message (array of bytes)

func (WSRawMessage) Bytes added in v0.13.0

func (m WSRawMessage) Bytes() []byte

Bytes returns the string representation of the raw message

type WSServer added in v0.5.0

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

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

func NewWSServer added in v0.5.0

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.13.0

func (s WSServer) OnDisconnected(c WSSpeaker)

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

type WSSpeaker added in v0.13.0

type WSSpeaker interface {
	GetStatus() WSConnStatus
	GetHost() string
	GetAddrPort() (string, int)
	GetServiceType() common.ServiceType
	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.13.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 WSSpeakerJSONMessageDispatcher added in v0.16.0

type WSSpeakerJSONMessageDispatcher interface {
	AddJSONMessageHandler(h WSSpeakerJSONMessageHandler, namespaces []string)
}

WSSpeakerJSONMessageDispatcher interface is used to dispatch OnWSJSONMessage events.

type WSSpeakerJSONMessageHandler added in v0.16.0

type WSSpeakerJSONMessageHandler interface {
	OnWSJSONMessage(c WSSpeaker, m *WSJSONMessage)
}

WSSpeakerJSONMessageHandler interface used to receive JSON messages.

type WSSpeakerPool added in v0.13.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.

Source Files

  • auth.go
  • basic.go
  • client.go
  • keystone.go
  • master.go
  • noauth.go
  • pool.go
  • server.go
  • tls.go
  • wsclient.go
  • wsjson.go
  • wsserver.go

Jump to

Keyboard shortcuts

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