Tell polling clients when we've recreated their connection and they need to resubscribe.
This commit is contained in:
2
api.py
2
api.py
@@ -75,6 +75,7 @@ def Poll(google_user, client, client_address, instance_id, args):
|
||||
|
||||
return {
|
||||
'result': 'ok',
|
||||
'new': instance.newly_created,
|
||||
'events': events,
|
||||
}
|
||||
|
||||
@@ -161,7 +162,6 @@ def Subscribe(google_user, client, client_address, instance_id, args):
|
||||
'result': 'access_denied',
|
||||
}
|
||||
|
||||
|
||||
if not instance or not instance.active:
|
||||
# Probably a race with the channel opening
|
||||
return {
|
||||
|
||||
@@ -104,7 +104,16 @@ class Instance(db.Model):
|
||||
@classmethod
|
||||
def FindOrCreate(cls, instance_id, **kwargs):
|
||||
logging.info('Instance: %s', instance_id)
|
||||
return cls.get_or_insert(instance_id, **kwargs)
|
||||
def _FindOrCreate():
|
||||
entity = cls.get_by_key_name(instance_id)
|
||||
if entity:
|
||||
entity.newly_created = False
|
||||
return entity
|
||||
entity = cls(key_name=instance_id, **kwargs)
|
||||
entity.put()
|
||||
entity.newly_created = True
|
||||
return entity
|
||||
return db.run_in_transaction(_FindOrCreate)
|
||||
|
||||
def Delete(self):
|
||||
logging.info('Deleting instance %s', self.key().name())
|
||||
|
||||
Reference in New Issue
Block a user