Documentation ¶
Overview ¶
Package common contains struts and interfaces shared between multiple components
Index ¶
- Constants
- func ActionCableProtocols() []string
- func ConfirmationMessage(identifier string) string
- func PubSubMessageFromJSON(raw []byte) (interface{}, error)
- func RejectionMessage(identifier string) string
- 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" DisconnectType = "disconnect" ConfirmedType = "confirm_subscription" RejectedType = "reject_subscription" // Not supported by Action Cable currently UnsubscribedType = "unsubscribed" )
Outgoing message types (according to Action Cable protocol)
const ( SERVER_RESTART_REASON = "server_restart" REMOTE_DISCONNECT_REASON = "remote" IDLE_TIMEOUT_REASON = "idle_timeout" UNAUTHORIZED_REASON = "unauthorized" )
Disconnect reasons
const (
ActionCableV1JSON = "actioncable-v1-json"
)
Variables ¶
This section is empty.
Functions ¶
func ActionCableProtocols ¶ added in v1.2.2
func ActionCableProtocols() []string
func ConfirmationMessage ¶ added in v1.2.0
ConfirmationMessage returns a subscription confirmation message for a specified identifier
func PubSubMessageFromJSON ¶
PubSubMessageFromJSON takes raw JSON byte array and return the corresponding struct
func RejectionMessage ¶ added in v1.2.0
RejectionMessage returns a subscription rejection message for a specified identifier
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 NewDisconnectMessage ¶ added in v1.2.3
func NewDisconnectMessage(reason string, reconnect bool) *DisconnectMessage
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,omitempty"` }
Message represents incoming client message
type PingMessage ¶ added in v1.0.3
type PingMessage struct { Type string `json:"type"` Message interface{} `json:"message,omitempty"` }
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,omitempty"` Message interface{} `json:"message,omitempty"` Reason string `json:"reason,omitempty"` Reconnect bool `json:"reconnect,omitempty"` }
Reply represents an outgoing client message
type SessionEnv ¶
type SessionEnv struct { URL string Headers *map[string]string Identifiers string ConnectionState *map[string]string ChannelStates *map[string]map[string]string }
SessionEnv represents the underlying HTTP connection data: URL and request headers. It also carries channel and connection state information used by the RPC app.
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
func (*StreamMessage) ToReplyFor ¶ added in v1.2.3
func (sm *StreamMessage) ToReplyFor(identifier string) *Reply