Skip to content

Commit

Permalink
Fixes googlearchive#45 - Support configuration of the xmppAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Leue committed Sep 20, 2016
1 parent 190e93b commit 74b5b49
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ const (
CCSControl = "control"
CCSReceipt = "receipt"
httpAddress = "https://gcm-http.googleapis.com/gcm/send"
xmppHost = "gcm.googleapis.com"
xmppPort = "5235"
xmppAddress = xmppHost + ":" + xmppPort

// For ccs the min for exponential backoff has to be 1 sec
ccsMinBackoff = 1 * time.Second
)
Expand All @@ -50,6 +48,7 @@ var (
// Default Min and Max delay for backoff.
DefaultMinBackoff = 1 * time.Second
DefaultMaxBackoff = 10 * time.Second
XmppAddress = "gcm.googleapis.com:5235"
retryableErrors = map[string]bool{
"Unavailable": true,
"SERVICE_UNAVAILABLE": true,
Expand Down Expand Up @@ -112,7 +111,7 @@ type HttpResponse struct {
Failure uint `json:"failure,omitempty"`
CanonicalIds uint `json:"canonical_ids,omitempty"`
Results []Result `json:"results,omitempty"`
MessageId int `json:"message_id,omitempty"`
MessageId int `json:"message_id,omitempty"`
Error string `json:"error,omitempty"`
}

Expand Down Expand Up @@ -249,7 +248,7 @@ func newXmppGcmClient(senderID string, apiKey string) (*xmppGcmClient, error) {
return xc, nil
}

nc, err := xmpp.NewClient(xmppAddress, xmppUser(senderID), apiKey, DebugMode)
nc, err := xmpp.NewClient(XmppAddress, xmppUser(senderID), apiKey, DebugMode)
if err != nil {
return nil, fmt.Errorf("error connecting client>%v", err)
}
Expand Down Expand Up @@ -602,5 +601,5 @@ func authHeader(apiKey string) string {

// xmppUser generates an xmpp username from a sender ID.
func xmppUser(senderId string) string {
return senderId + "@" + xmppHost
return senderId + "@gcm.googleapis.com"
}

0 comments on commit 74b5b49

Please sign in to comment.