Answer the question
In order to leave comments, you need to log in
Is it possible to use websocket in Rails without users?
Good time of the day. I am writing a trello clone using React + Rails.
There is a need to use web sockets for real time updates. Many of the websocket creation examples use users. That is, there is no registration and authorization, there are no users. There are only 3 models - Board, List, Card, as I understand it, use a web socket just for a permanent connection between the front and the server.
And actually the question is:
Can it be used in some way without authorization? . And if possible, how? What is the path for implementation?
(maybe a stupid question, sorry :))
Answer the question
In order to leave comments, you need to log in
Can. Use Broadcast.
class MessagesChannel < ApplicationCable::Channel
def subscribed
stream_from "messages"
end
end
(function() {
this.App || (this.App = {});
App.cable = ActionCable.createConsumer('/cable');
}).call(this);
ActionCable.server.broadcast('messages', message.to_json)
App.messages = App.cable.subscriptions.create('MessagesChannel', {
received: function(data) {
var jsonObj = JSON.parse(data);
....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question