NVentimiglia / Realtime.Messaging.Xamarin

Realtime.co websockets in Xamarin
http://framework.realtime.co/
28 stars 9 forks source link

How to adapt sample to use Realtime Storage? #6

Closed MattHarrington closed 8 years ago

MattHarrington commented 8 years ago

How would you adapt the sample to use Realtime Storage for message persistence in a group chat app? There doesn't appear to be a Xamarin SDK for Realtime Storage, so I'm guessing the REST API is the one to use. I don't see on, once, and off in the REST API.

I see that a Storage subscription and its corresponding Messaging subscription share the same application and private keys. I can imagine connecting to Messaging using the Xamarin SDK and Storage using REST, both using the same app key, but it's not clear how to get Storage to post notifications via Messaging without using on or once.

jparreira commented 8 years ago

When data is updated in a Storage table via REST API (putItem, updateItem or deleteItem), the Storage server handling the request will publish an update message in the appropriate Realtime Messaging channel if the operation succeeds.

The Storage client SDKs simply subscribe the appropriate Messaging channel when an on or once method is called and unsubscribe when the off method is called.

To know the details of the putItem update notification (channel name and payload object) please have a look at the Notifications section of http://storage-public.realtime.co/documentation/rest/1.0.0/realtime.storage.function.putitem.html

jparreira commented 8 years ago

Forgot to mention that you must use a specific Realtime Messaging cluster url to receive the notifications messages: http://ortc-storage.realtime.co/server/2.1

MattHarrington commented 8 years ago

Thanks. I had overlooked that section of the documentation. I'm now able to use the REST API to store an item, and Realtime.Messaging.Xamarin to receive the corresponding message.