|
In Rejaw, various types of events can be notified in realtime manner using Comet. Here is the basic steps how it works: - Create a session by session.create
- Subscribe to topics on which you want to receive events, such as "/user/foo/shouts". The subscriptions will be associated with the session. Some topics require auth.signin for the session.
- Start an event.observe loop by sending an HTTP request to event servers. The HTTP request will be responded to when an event occurs on one of the topics to which you are subscribed.
- The response includes a list of events that occured. Each event includes a topic attribute, so you can dispatch it to the appropriate function based on the topic.
- After the HTTP request is responded to, you should reconnect to event.observe with the renewed event counter as soon as possible.
Available subscriptions are listed here.
subscription.subscribeWith this method, you are able to subscribe to topics, on which the events are delivered. URL: - http://api.rejaw.com/v1/subscription/subscribe
Parameters: | session * | Session ID is required. | | topic * | Topics to which you wish to subscribe. Available subscriptions are listed here. If you want to specify multiple topics, separate them by comma. (e.g. "/user/foo/shouts,/user/bar/profile") |
(*) Required <response>
<status>ok</status>
<counter>0</counter>
</response> {"status": "ok", "counter": 0}
subscription.unsubscribeYou can stop subscribing from a topic by this method. URL: - http://api.rejaw.com/v1/subscription/unsubscribe
Parameters: | session * | Session ID is required. | | topic * | Topics you want to unsubscribe. If you want to specify multiple topics, separate them by comma. (e.g. "/user/foo/shouts,/user/bar/profile") |
(*) Required <response>
<status>ok</status>
</response> {"status": "ok"}
|