Documentation ¶
Index ¶
- func ConstructACK(registrationID, messageID string) ([]byte, error)
- type ACKPayload
- type BodyStanza
- type ClientError
- type ConnectionDrainingMessage
- type DownstreamPayload
- type FCMMessage
- type FirebaseClient
- type GCMStanza
- type InboundACKMessage
- type MessageStanza
- type NACKMessage
- type Signal
- type SignalType
- type UpstreamMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructACK ¶
ConstructACK constructs a full ACK message to be send to the server.
Types ¶
type ACKPayload ¶
type ACKPayload struct { To string `json:"to"` MessageID string `json:"message_id"` MessageType string `json:"message_type"` }
ACKPayload stores the data in the ACK payload. Used for marshalling JSON.
func NewACKPayload ¶
func NewACKPayload(registrationID, messageID string) ACKPayload
NewACKPayload makes a new ACKPayload. MessageType should always be ack.
type BodyStanza ¶
BodyStanza stores the data in the body stanza in outgoing messages. Used for marshalling XML.
type ClientError ¶
type ClientError struct { Client *FirebaseClient Err error Fatal bool }
ClientError represents an error that occurs within a cient
type ConnectionDrainingMessage ¶
type ConnectionDrainingMessage struct{}
ConnectionDrainingMessage indicates a CONNECTION_DRAINING message.
func (ConnectionDrainingMessage) PerformAction ¶
func (message ConnectionDrainingMessage) PerformAction(client *FirebaseClient) error
PerformAction informs the signal channel that this connection needs to be drained.
type DownstreamPayload ¶
type DownstreamPayload struct { To string `json:"to,omitempty"` Condition string `json:"condition,omitempty"` MessageID string `json:"message_id"` CollapseKey string `json:"collapse_key,omitempty"` Priority string `json:"priority,omitempty"` TTL int `json:"time_to_live,omitempty"` DeliveryReceiptRequested bool `json:"delivery_receipt_requested,omitempty"` DryRun bool `json:"dry_run,omitempty"` Data interface{} `json:"data,omitempty"` Notification bool `json:"notification,omitempty"` }
DownstreamPayload stores the data to be sent downstream. Used for marshaling JSON. Because our client is Android specific, we ignore content_availabe and mutable_content, which do nothing for Android.
type FCMMessage ¶
type FCMMessage interface {
PerformAction(client *FirebaseClient) error
}
FCMMessage represents a single message from FCM
type FirebaseClient ¶
type FirebaseClient struct { ClientID string // contains filtered or unexported fields }
FirebaseClient stores the data necessary to be an XMPP Client for Firebase Cloud Messaging. See the spec at https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref senderID and severKey refer to their corresponding FCM properties. ClientID is simply an id to identify clients. It can safely be ommitted, but your connectionClosedCallback will receive an empty string Note that Signal will recieve pointer types of signals such as *ConnectionDrainingSignal and *ConnectionClosedSignal rather than ConnectionDrainingSignal and ConnectionClosedSignal respectively.
func NewFirebaseClient ¶
func NewFirebaseClient(clientID string, recvChannel chan<- UpstreamMessage, sendChannel <-chan DownstreamPayload, signalChannel chan<- Signal, errorChannel chan<- ClientError) (FirebaseClient, error)
NewFirebaseClient creates a FirebaseClient from the given XMPPConfig
func (*FirebaseClient) ListenForSend ¶
func (client *FirebaseClient) ListenForSend()
ListenForSend listens for a message on sendChannel and sends the message. Terminates when sendChannel is closed
func (*FirebaseClient) StartRecv ¶
func (client *FirebaseClient) StartRecv()
StartRecv listens for incoming messages from Firebase Cloud Messaging and acts on them as defined by their type of message.
type GCMStanza ¶
type GCMStanza struct { XMLName xml.Name `xml:"gcm"` XMLNS string `xml:"xmlns,attr"` Value string `xml:",innerxml"` //A bit of a hack, but it works. Chardata escaped our JSON, but innerxml will not. }
GCMStanza stores the data in the gcm stanza in outgoing messages. Used for marshalling XML.
func NewGCMStanza ¶
NewGCMStanza makes a new GCMStanza. the XMLNS should always be google:mobile:data.
type InboundACKMessage ¶
InboundACKMessage stores the basic data from an ACK message that Firebase CLoud Messaging when we send a message downstream.
func (InboundACKMessage) PerformAction ¶
func (message InboundACKMessage) PerformAction(client *FirebaseClient) error
PerformAction is a stub to satisfy the FCMMessage interface. Presently, there is no mechanism in place to wait for an ACK, so we're just stubbing this.
type MessageStanza ¶
type MessageStanza struct { XMLName xml.Name `xml:"message"` To string `xml:"to,attr,omitempty"` Type string `xml:"type,attr,omitempty"` ID string `xml:"id,attr,omitempty"` Body interface{} }
MessageStanza stores the data from the message stanza in outgoing messages. Used for marshalling XML.
type NACKMessage ¶
type NACKMessage struct { From string `json:"from"` MessageID string `json:"message_id"` Error string `json:"error"` ErrorDescription string `json:"error_description"` }
NACKMessage stores the basic data from an NACK message that Firebase CLoud Messaging when we send a message downstream.
func (NACKMessage) PerformAction ¶
func (message NACKMessage) PerformAction(client *FirebaseClient) error
PerformAction will return a properly formatted error object for the error given by FCM.
type Signal ¶
type Signal struct { Client *FirebaseClient Type SignalType }
Signal represents a signal to the XMPP supervisor
func NewConnectionClosedSignal ¶
func NewConnectionClosedSignal(client *FirebaseClient) Signal
NewConnectionClosedSignal is a convenience function to construct a Signal with type ConnectionDrainingSignal
func NewConnectionDrainingSignal ¶
func NewConnectionDrainingSignal(client *FirebaseClient) Signal
NewConnectionDrainingSignal is a convenience function to construct a Signal with type ConnectionDrainingSignal
type SignalType ¶
type SignalType int
SignalType represents the type of signal produced by FCM
const ( //ConnectionDrainingSignal represents a CONNCETION_DRAINING signal from FCM, which tells us to prepare for this connection to be closed. ConnectionDrainingSignal SignalType = iota //ConnectionClosedSignal represents a signal to the supervisor that this connection is closed. ConnectionClosedSignal )
type UpstreamMessage ¶
type UpstreamMessage struct { From string `json:"from"` TTL int `json:"time_to_live"` MessageID string `json:"message_id"` Category string `json:"category"` Data json.RawMessage }
UpstreamMessage stores the basic data from any upstream Firebase Cloud Messaging XML Message. This isn't as general as it could be. Because the app only sends SMS/MMSes upstream, TextMessage is included in UpstreamMessage.
func (UpstreamMessage) PerformAction ¶
func (message UpstreamMessage) PerformAction(client *FirebaseClient) error
PerformAction sends the SMS message upstream to the main program