Skip to content
Browse files

enable sound

  • Loading branch information...
1 parent 93e4584 commit b55660c6b76b4f4fafcff3997d78f7f6dfabc022 @stliu committed Jan 24, 2014
Showing with 8 additions and 1 deletion.
  1. +1 −0 lib/payload.coffee
  2. +7 −1 lib/subscriber.coffee
View
1 lib/payload.coffee
@@ -7,6 +7,7 @@ class Payload
throw new Error('Invalid payload') unless typeof data is 'object'
logger.verbose "get payload data: #{util.inspect(data)}"
@id = serial++
+ @sound = 'default'
# Read fields
for own key, value of data
if typeof key isnt 'string' or key.length == 0
View
8 lib/subscriber.coffee
@@ -10,18 +10,21 @@ class Subscriber
throw new Error("Missing redis connection") if not redis?
throw new Error("Missing mandatory `proto' field") if not proto?
throw new Error("Missing mandatory `token' field") if not token?
-
+ logger.verbose "############################ getInstanceFromToken using proto[#{proto}] and token[#{token}] "
redis.hget "tokenmap", "#{proto}:#{token}", (err, id) =>
if id?
+ logger.verbose "######################## found id[#{id}]"
# looks like this subscriber is already registered
redis.exists "subscriber:#{id}", (err, exists) =>
if exists
+ logger.verbose "################ subscriber:#{id} exist"
cb(new Subscriber(redis, id))
else
# duh!? the global list reference an unexisting object, fix this inconsistency and return no subscriber
redis.hdel "tokenmap", "#{proto}:#{token}", =>
cb(null)
else
+ logger.verbose "########################## can't find the push id"
cb(null) # No subscriber for this token
create: (redis, fields, cb, tentatives=0) ->
@@ -38,12 +41,15 @@ class Subscriber
# verify if token is already registered
Subscriber::getInstanceFromToken redis, fields.proto, fields.token, (subscriber) =>
if subscriber?
+ logger.verbose "--------- found the subscriber, now update subscriber info"
# this subscriber is already registered
delete fields.token
delete fields.proto
+ logger.verbose(fields)
subscriber.set fields, =>
cb(subscriber, created=false, tentatives)
else
+ logger.verbose("------------ generating a new subscriber")
# register the subscriber using a randomly generated id
crypto.randomBytes 8, (ex, buf) =>
# generate a base64url random uniq id

0 comments on commit b55660c

Please sign in to comment.
Something went wrong with that request. Please try again.