Documentation ¶
Index ¶
- type Address
- type Cluster
- type Connection
- type ConnectionHandler
- type ConnectionId
- type Origin
- type OriginFunc
- type OriginRequest
- type OutgoingWebSocketMessage
- type Service
- type ServiceRequest
- type WebSocketEvent
- type WebSocketEventConnectionClosed
- type WebSocketEventConnectionEstablished
- type WebSocketKeepAlive
- type WebSocketMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster interface { // Returns the address of the local node. Other nodes in the cluster should be able to send // messages to this node using this address. Address() Address SendServiceRequest(address Address, r *ServiceRequest) error }
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(conn *websocket.Conn, logger logrus.FieldLogger, handler ConnectionHandler) *Connection
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) Send ¶
func (c *Connection) Send(msg *websocket.PreparedMessage)
type ConnectionHandler ¶
type ConnectionHandler interface { HandleWebSocketMessage(msg *WebSocketMessage) HandleClose() }
type ConnectionId ¶
type ConnectionId []byte
func NewConnectionId ¶
func NewConnectionId(address Address) (ConnectionId, error)
func (ConnectionId) Address ¶
func (id ConnectionId) Address() Address
func (ConnectionId) String ¶
func (id ConnectionId) String() string
type Origin ¶
type Origin interface {
SendOriginRequest(*OriginRequest) error
}
type OriginFunc ¶
type OriginFunc func(*OriginRequest) error
func (OriginFunc) SendOriginRequest ¶
func (f OriginFunc) SendOriginRequest(r *OriginRequest) error
type OriginRequest ¶
type OriginRequest struct { WebSocketEvent *WebSocketEvent // The service will periodically send keep-alives, which don't represent actual websocket // events, but just let you know the connections are still alive and well. WebSocketKeepAlives []*WebSocketKeepAlive }
type OutgoingWebSocketMessage ¶
type OutgoingWebSocketMessage struct { ConnectionIds []ConnectionId Message *WebSocketMessage }
type Service ¶
type Service struct { // The subprotocols to advertise during WebSocket negotiation. Subprotocols []string // Origin provides a means of sending messages to the origin server. Origin Origin // Cluster provides a means of sending messages to other nodes in the cluster. Cluster Cluster // If non-zero, the origin will receive keep-alive events for WebSocket connections. These // events don't represent any actual WebSockett activity, but indicate that the connection is // still alive and healthy. KeepAliveInterval time.Duration // The logger to use. If nil, the standard logger will be used. Logger logrus.FieldLogger // contains filtered or unexported fields }
func (*Service) CloseConnection ¶
func (s *Service) CloseConnection(id ConnectionId) error
func (*Service) ConnectionCount ¶
func (*Service) HandleServiceRequest ¶
func (s *Service) HandleServiceRequest(r *ServiceRequest)
type ServiceRequest ¶
type ServiceRequest struct {
OutgoingWebSocketMessages []*OutgoingWebSocketMessage
}
type WebSocketEvent ¶
type WebSocketEvent struct { ConnectionId ConnectionId ConnectionEstablished *WebSocketEventConnectionEstablished ConnectionClosed *WebSocketEventConnectionClosed MessageReceived *WebSocketMessage }
type WebSocketEventConnectionClosed ¶
type WebSocketEventConnectionClosed struct{}
type WebSocketEventConnectionEstablished ¶
type WebSocketEventConnectionEstablished struct {
Subprotocol string
}
type WebSocketKeepAlive ¶
type WebSocketKeepAlive struct {
ConnectionId ConnectionId
}
type WebSocketMessage ¶
func (*WebSocketMessage) PreparedMessage ¶
func (msg *WebSocketMessage) PreparedMessage() (*websocket.PreparedMessage, error)
Click to show internal directories.
Click to hide internal directories.