Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Generate new UAID if one or more channelIDs sent by client are unknown. #19

Merged
merged 1 commit into from

2 participants

@nikhilm
Collaborator

No description provided.

@dougt dougt merged commit 0c9a25a into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 9 deletions.
  1. +25 −9 src/mozilla.org/push/server.go
View
34 src/mozilla.org/push/server.go
@@ -239,24 +239,40 @@ func handleHello(client *Client, f map[string]interface{}) {
} else {
client.UAID = f["uaid"].(string)
- // BUG(nikhilm): Does not deal with sending
- // a new UAID if their is a channel that was sent
- // by the UA which the server does not know about.
- // Which means in the case of this memory only server
- // it should actually always send a new UAID when it was
- // restarted
+ resetClient := false
+
if f["channelIDs"] != nil {
for _, foo := range f["channelIDs"].([]interface{}) {
channelID := foo.(string)
if gServerState.UAIDToChannelIDs[client.UAID] == nil {
gServerState.UAIDToChannelIDs[client.UAID] = make(ChannelIDSet)
+ // since we don't have any channelIDs, don't bother looping any more
+ resetClient = true
+ break
+ }
+
+ if _, ok := gServerState.UAIDToChannelIDs[client.UAID][channelID]; !ok {
+ resetClient = true
+ break
}
- c := &Channel{client.UAID, channelID, 0}
- gServerState.UAIDToChannelIDs[client.UAID][channelID] = c
- gServerState.ChannelIDToChannel[channelID] = c
}
}
+
+ if resetClient {
+ // delete the older connection
+ delete(gServerState.ConnectedClients, client.UAID)
+ delete(gServerState.UAIDToChannelIDs, client.UAID)
+ // TODO(nsm) clear up ChannelIDToChannels which now has extra
+ // channelIDs not associated with any client
+
+ uaid, err := uuid.GenUUID()
+ if err != nil {
+ status = 400
+ log.Println("GenUUID error %s", err)
+ }
+ client.UAID = uaid
+ }
}
gServerState.ConnectedClients[client.UAID] = client
Something went wrong with that request. Please try again.