Demo chat for Rails 5 API-only using ActionCable and Devise Authentication.
If using sideway client (e.g. Simple Web Socket Client for Google Chrome):
- Sign in via HTTP as:
POST http://localhost:3000/api/auth/[email protected]&password=12345678
You'll get back these headers:
access-token: BndOS3qh9zJF4Nc4cfOFDA client: MhTwe4aEftJzOFv0dbO8Qg uid: [email protected]
Use these headers for Basic Websockets Authorisation:
-
Connect: ws://localhost:3000/cable/?access-token=BndOS3qh9zJF4Nc4cfOFDA&client=MhTwe4aEftJzOFv0dbO8Qg&uid=[email protected]
-
Subscribe: {"command":"subscribe","identifier":"{"channel":"RoomChannel","access-token":"BndOS3qh9zJF4Nc4cfOFDA","client":"MhTwe4aEftJzOFv0dbO8Qg","uid":"[email protected]"}"}
-
Send message: {"command":"message","identifier":"{"channel":"RoomChannel","access-token":"BndOS3qh9zJF4Nc4cfOFDA","client":"MhTwe4aEftJzOFv0dbO8Qg","uid":"[email protected]"}","data":"{"name":"debug","content":"debug","action":"process_message_on_server"}"}