1

Is there any way to get the Channel ID on the server or transmit it inside a RequestFactory call?

Situation:

  • User starts the application, a channel is being opened.
  • User persists an entity with RequestFactory (requests.persist().using(...).fire(...)).
  • The persist() method on the server pings all connected clients to tell them that the entity has been updated.

But the user that made the initial change doesn't have to be pinged. Is there a way to find out which client made the change? It's not enough to know the user, because one user may have opened several windows (channels).

Dominik
  • 706
  • 7
  • 22
  • Could you show how you "ping" clients ? – expert Mar 02 '12 at 03:45
  • `CHANNEL_SERVICE.sendMessage(new ChannelMessage(clientId, message.toString()));` `message` is the id of the model that has changed. The client then reloads this model (`requests.modelRequest().findModel(id).fire(modelReceiver);`). – Dominik Mar 02 '12 at 10:40

1 Answers1

0

Honestly I haven't used Channel API yet but according to documentation each client is treated as separate user. So the solution lies beyond GAE API and I think you have two options:

  1. Create logical User ID on the client that will be mapped to possibly multiple channels. That way you'll know what channels to skip.
  2. Ping all channels anyway but send numeric Version of newly persisted entity. Then client will compare received version with what it has and if it's higher it means it needs to call findModel(id) again.
expert
  • 29,290
  • 30
  • 110
  • 214
  • 1. In that case the server still doesn't know which request was made by which client. 2. That might be a solution. – Dominik Mar 03 '12 at 01:00
  • Yep, looks like #2 is straightforward option here. – expert Mar 03 '12 at 01:33
  • But this only works if I do send back things that have a version. I was thinking about overriding some RequestFactory calls to automatically send the clientId with every request. – Dominik Mar 03 '12 at 08:38