Documentation
¶
Overview ¶
Package gcm provides send and receive GCM functionality.
Package gcm provides send and receive GCM functionality.
Package gcm provides send and receive GCM functionality.
Index ¶
Constants ¶
const ( // DefaultMinBackoff is a default min delay for backoff. DefaultMinBackoff = 1 * time.Second // DefaultMaxBackoff is the default max delay for backoff. DefaultMaxBackoff = 10 * time.Second )
const ( // DefaultPingInterval is a default interval between pings. DefaultPingInterval = 20 * time.Second // DefaultPingTimeout is a default time to wait for ping replies. DefaultPingTimeout = 30 * time.Second // CCSAck is a positive acknowledge. CCSAck = "ack" // CCSNack is a negative acknowledge. CCSNack = "nack" // CCSControl is a CCS upstream control message. CCSControl = "control" // CCSReceipt is an upstream receipt message. CCSReceipt = "receipt" // CCSDraining is an upstream CSS message it wants to drain the current connection. CCSDraining = "CONNECTION_DRAINING" // XMPPIQResult is a result for IQ query. XMPPIQResult = "result" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CCSMessage ¶ added in v1.5.0
type CCSMessage struct {
From string `json:"from, omitempty"`
MessageID string `json:"message_id, omitempty"`
MessageType string `json:"message_type, omitempty"`
RegistrationID string `json:"registration_id,omitempty"`
Error string `json:"error,omitempty"`
ErrorDescription string `json:"error_description,omitempty"`
Category string `json:"category, omitempty"`
Data Data `json:"data,omitempty"`
ControlType string `json:"control_type,omitempty"`
}
CCSMessage is an XMPP message sent from CCS. The CCS message can be an upstream message (device to server) or a message from CCS (e.g. a delivery receipt, a control, etc).
type Client ¶ added in v1.5.0
type Client interface {
ID() string
SendHTTP(m HTTPMessage) (*HTTPResponse, error)
SendXMPP(m XMPPMessage) (string, int, error)
Close() error
}
Client defines an interface for the GCM client.
type Config ¶ added in v1.5.0
type Config struct {
SenderID string `json:"sender_id"`
APIKey string `json:"api_key"`
Sandbox bool `json:"sandbox"`
MonitorConnection bool `json:"monitor_connection"`
Debug bool `json:"debug"`
PingInterval int `json:"ping_interval"`
PingTimeout int `json:"ping_timeout"`
}
Config is a container for GCM client configuration data.
type HTTPMessage ¶ added in v1.5.0
type HTTPMessage struct {
To string `json:"to,omitempty"`
RegistrationIDs []string `json:"registration_ids,omitempty"`
CollapseKey string `json:"collapse_key,omitempty"`
Priority string `json:"priority,omitempty"`
ContentAvailable bool `json:"content_available,omitempty"`
MutableContent bool `json:"mutable_content,omitempty"`
TimeToLive *uint `json:"time_to_live,omitempty"`
RestrictedPackageName string `json:"restricted_package_name,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
Data Data `json:"data,omitempty"`
Notification *Notification `json:"notification,omitempty"`
}
HTTPMessage defines a downstream GCM HTTP message.
type HTTPResponse ¶ added in v1.5.0
type HTTPResponse struct {
StatusCode int `json:"-"`
MulticastID int64 `json:"multicast_id"`
Success uint `json:"success"`
Failure uint `json:"failure"`
CanonicalIds uint `json:"canonical_ids"`
Results []HTTPResult `json:"results,omitempty"`
// Topic message HTTP response only.
MessageID uint `json:"message_id,omitempty"`
Error string `json:"error,omitempty"`
}
HTTPResponse is the GCM connection server response to an HTTP downstream message.
type HTTPResult ¶ added in v1.5.0
type HTTPResult struct {
MessageID string `json:"message_id,omitempty"`
RegistrationID string `json:"registration_id,omitempty"`
Error string `json:"error,omitempty"`
}
HTTPResult represents the result of a single processed HTTP request.
type MessageHandler ¶
type MessageHandler func(cm CCSMessage) error
MessageHandler is the type for a function that handles a CCS message.
type Notification ¶
type Notification struct {
// Common fields.
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Sound string `json:"sound,omitempty"`
ClickAction string `json:"click_action,omitempty"`
BodyLocKey string `json:"body_loc_key,omitempty"`
BodyLocArgs string `json:"body_loc_args,omitempty"`
TitleLocKey string `json:"title_loc_key,omitempty"`
TitleLocArgs string `json:"title_loc_args,omitempty"`
// Android-only fields.
Icon string `json:"icon,omitempty"`
Tag string `json:"tag,omitempty"`
Color string `json:"color,omitempty"`
// iOS-only fields
Badge string `json:"badge,omitempty"`
MutableContent bool `json:"mutable_content,omitempty"`
}
Notification defines the notification payload of a GCM message. NOTE: contains keys for both Android and iOS notifications.
type XMPPMessage ¶ added in v1.5.0
type XMPPMessage struct {
To string `json:"to,omitempty"`
MessageID string `json:"message_id"`
MessageType string `json:"message_type,omitempty"`
CollapseKey string `json:"collapse_key,omitempty"`
Priority string `json:"priority,omitempty"`
ContentAvailable bool `json:"content_available,omitempty"`
MutableContent bool `json:"mutable_content,omitempty"`
TimeToLive *uint `json:"time_to_live,omitempty"`
DeliveryReceiptRequested bool `json:"delivery_receipt_requested,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
Data Data `json:"data,omitempty"`
Notification *Notification `json:"notification,omitempty"`
}
XMPPMessage defines a downstream GCM XMPP message.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gcm-logger
command
Program gcm-logger logs and echoes as a GCM "server".
|
Program gcm-logger logs and echoes as a GCM "server". |