2

I am trying to create a RESTful API for the first time.

Sending Request(Client to Server) and Response(Server to Client) using Action Cable.

How to send request from other Applications(like Android/iOS App, Web App'n or Desktop App'n) and give response to the application.

I have used Action Cable in normal Web Application.

Please provide me some links with guides of ActionCable usage in Rails 5 RESTful API.

Thanks in Advance.

Viktor
  • 4,218
  • 4
  • 32
  • 63
  • Possible duplicate of [Connecting to ActionCable from iOS app](http://stackoverflow.com/questions/35145429/connecting-to-actioncable-from-ios-app) – Viktor Oct 30 '16 at 11:34

1 Answers1

2

Here is the detail to use Action Cable as Restful API.

  1. Use following JSON for subscription.

    { "command": "subscribe", "identifier": { "channel": "CHANEL_NAME" } }

  2. Use following JSON for model subscription.

    { "command": "subscribe", "identifier": { "channel": "CHANEL_NAME", "post_id": 1 } }

  3. Use following JSON to call any method in channel.

    { "command": "message", "identifier": { "channel": "CHANEL_NAME" }, "data": { "action": "ACTION_NAME", .... } }

faisal bhatti
  • 325
  • 2
  • 12