Documentation
¶
Overview ¶
Package common contains struts and interfaces shared between multiple components
Index ¶
- Constants
- func PubSubMessageFromJSON(raw []byte) (interface{}, error)
- type CallResult
- type CommandResult
- type ConnectResult
- type DisconnectMessage
- type Message
- type PingMessage
- type RemoteCommandMessage
- type RemoteDisconnectMessage
- type Reply
- type SessionEnv
- func (st *SessionEnv) GetChannelStateField(id string, field string) string
- func (st *SessionEnv) GetConnectionStateField(field string) string
- func (st *SessionEnv) MergeChannelState(id string, other *map[string]string)
- func (st *SessionEnv) MergeConnectionState(other *map[string]string)
- func (st *SessionEnv) SetHeader(key string, val string)
- type StreamMessage
Constants ¶
const ( SUCCESS = iota FAILURE ERROR )
Command result status
const ( WelcomeType = "welcome" PingType = "ping" ReplyType = "message" DisconnectType = "disconnect" ConfirmedType = "confirm_subscription" RejectedType = "reject_subscription" // Not suppurted by Action Cable currently UnsubscribedType = "unsubscribed" )
Outgoing message types (according to Action Cable protocol)
Variables ¶
This section is empty.
Functions ¶
func PubSubMessageFromJSON ¶
PubSubMessageFromJSON takes raw JSON byte array and return the corresponding struct
Types ¶
type CallResult ¶
type CallResult struct {
Transmissions []string
Broadcasts []*StreamMessage
CState map[string]string
IState map[string]string
}
CallResult contains shared RPC result fields
type CommandResult ¶
type CommandResult struct {
StopAllStreams bool
Disconnect bool
Streams []string
StoppedStreams []string
Transmissions []string
Broadcasts []*StreamMessage
CState map[string]string
IState map[string]string
Status int
}
CommandResult is a result of performing controller action, which contains informations about streams to subscribe, messages to sent and broadcast. It's a communication "protocol" between a node and a controller.
func (*CommandResult) ToCallResult ¶
func (c *CommandResult) ToCallResult() *CallResult
ToCallResult returns the corresponding CallResult
type ConnectResult ¶
type ConnectResult struct {
Identifier string
Transmissions []string
Broadcasts []*StreamMessage
CState map[string]string
IState map[string]string
Status int
}
ConnectResult is a result of initializing a connection (calling a Connect method)
func (*ConnectResult) ToCallResult ¶
func (c *ConnectResult) ToCallResult() *CallResult
ToCallResult returns the corresponding CallResult
type DisconnectMessage ¶ added in v1.0.3
type DisconnectMessage struct {
Type string `json:"type"`
Reason string `json:"reason"`
Reconnect bool `json:"reconnect"`
}
DisconnectMessage represents a server disconnect message
func (*DisconnectMessage) GetType ¶ added in v1.1.0
func (d *DisconnectMessage) GetType() string
type Message ¶
type Message struct {
Command string `json:"command"`
Identifier string `json:"identifier"`
Data interface{} `json:"data"`
}
Message represents incoming client message
type PingMessage ¶ added in v1.0.3
type PingMessage struct {
Type string `json:"type"`
Message interface{} `json:"message"`
}
PingMessage represents a server ping
func (*PingMessage) GetType ¶ added in v1.1.0
func (p *PingMessage) GetType() string
type RemoteCommandMessage ¶
type RemoteCommandMessage struct {
Command string `json:"command,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
}
RemoteCommandMessage represents a pub/sub message with a remote command (e.g., disconnect)
type RemoteDisconnectMessage ¶
type RemoteDisconnectMessage struct {
Identifier string `json:"identifier"`
Reconnect bool `json:"reconnect"`
}
RemoteDisconnectMessage contains information required to disconnect a session
type Reply ¶ added in v1.0.3
type Reply struct {
Type string `json:"type,omitempty"`
Identifier string `json:"identifier"`
Message interface{} `json:"message"`
}
Reply represents an outgoing client message
type SessionEnv ¶
type SessionEnv struct {
URL string
Headers *map[string]string
ConnectionState *map[string]string
ChannelStates *map[string]map[string]string
}
SessionEnv represents the underlying HTTP connection data: URL and request headers
func NewSessionEnv ¶
func NewSessionEnv(url string, headers *map[string]string) *SessionEnv
NewSessionEnv builds a new SessionEnv
func (*SessionEnv) GetChannelStateField ¶ added in v1.1.4
func (st *SessionEnv) GetChannelStateField(id string, field string) string
Returns a value for the specified key of the specified channel
func (*SessionEnv) GetConnectionStateField ¶ added in v1.1.4
func (st *SessionEnv) GetConnectionStateField(field string) string
Returns a value for the specified connection state field
func (*SessionEnv) MergeChannelState ¶
func (st *SessionEnv) MergeChannelState(id string, other *map[string]string)
MergeChannelState updates the current ChannelStates for the given identifier. If the value is an empty string then remove the key, otherswise add or rewrite.
func (*SessionEnv) MergeConnectionState ¶
func (st *SessionEnv) MergeConnectionState(other *map[string]string)
MergeConnectionState updates the current ConnectionState from the given map. If the value is an empty string then remove the key, otherswise add or rewrite.
func (*SessionEnv) SetHeader ¶ added in v1.1.2
func (st *SessionEnv) SetHeader(key string, val string)
SetHeader adds a header to the headers list
type StreamMessage ¶
StreamMessage represents a pub/sub message to be sent to stream