Fix handling of initial messages on channel creation by returning them in the

RPC response instead of over the channel.
This commit is contained in:
Ian Gulliver
2014-03-25 14:19:13 -07:00
parent f01d7a4dc9
commit 7069d16aaa
3 changed files with 34 additions and 22 deletions

11
api.py
View File

@@ -66,10 +66,11 @@ class SetValue(webapp2.RequestHandler):
entry_value=entry_value)
entry.put()
clients = (models.Client.all(keys_only=True)
msg = entry.ToMessage()
clients = (models.Client.all()
.ancestor(self.client.parent_key()))
for client in clients:
entry.SendToClient(client)
client.SendMessage(msg)
return {}
@@ -108,12 +109,10 @@ class CreateChannel(webapp2.RequestHandler):
token = channel.create_channel(
client_id=str(self.client.key()),
duration_minutes=config.CHANNEL_DURATION_SECONDS / 60)
entries = (models.StateEntry.all()
.ancestor(self.client.parent_key()))
for entry in entries:
entry.SendToClient(self.client.key())
return {
'token': token,
'messages': [x.ToMessage()
for x in self.client.parent().GetStateEntries()],
}