0

I am using PubNub to create a Chat. Each chatroom is a PubNub channel. The challenge now is: how do I sort my channels such that channels with most recent posts should be on top.

I can think on 2 possibilities:

  • Server will listen to all channels, when a message is received, it logs it. So a chatroom model might look like {id, name, users, lastUpdate}
  • Everytime message is posted, app will also call server to pass in that message

Both methods doesnt seem to correct? Is there a better way? The first will require the server to listen on all channels. The second will require server to handle a request for each message.

Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

1 Answers1

0

How about using timestamp?

Actually, PubNub offers Presence APIs that lets you monitor the state of each channel, with timestamp (which specified as 17-digit precision unix time).

http://www.pubnub.com/knowledge-base/discussion/276/presence

girlie_mac
  • 593
  • 5
  • 7