actioncable

Actioncable authentication with multiple Devise models

走远了吗. 提交于 2020-01-06 06:48:28
问题 I am currently implementing a chat between 2 of my Devise models. Client and Professionnel . It is working just fine at the moment but I have only one channel: every Client or Professionnel receive all messages from all clients and all professionals. The displaying is fine but someone who watches their AJAX flow can see every private message that is not meant for them.. As per this thread http://www.thegreatcodeadventure.com/rails-5-action-cable-with-multiple-chatroom-subscriptions/ this is

Actioncable authentication with multiple Devise models

半城伤御伤魂 提交于 2020-01-06 06:48:14
问题 I am currently implementing a chat between 2 of my Devise models. Client and Professionnel . It is working just fine at the moment but I have only one channel: every Client or Professionnel receive all messages from all clients and all professionals. The displaying is fine but someone who watches their AJAX flow can see every private message that is not meant for them.. As per this thread http://www.thegreatcodeadventure.com/rails-5-action-cable-with-multiple-chatroom-subscriptions/ this is

ActionCable(Rails5) and Android client

别来无恙 提交于 2020-01-05 06:06:40
问题 I'm using as backend framework Ruby on Rails 5, actually action cable for websocket connection and as front end Android. I create server as said in https://github.com/rails/actioncable-examples and for client connection use library https://github.com/hosopy/actioncable-client-java. When I'm connecting to the server it every time fails with exception: Started GET "/cable" for 192.168.0.106 at 2017-06-15 17:57:19 +0500 Cannot render console from 192.168.0.106! Allowed networks: 127.0.0.1, ::1,

Find Image of Messaged User associated with chatrooms using Group Chat via Actioncable

主宰稳场 提交于 2020-01-05 05:50:35
问题 Apologies for the basic question. I managed to follow tutorials and with the help of the SO community managed to build a Group Chat with Action Cable and learned loads from doing so. However, I'm trying to pull up on a specific html page - the image of a Messaged User associated with a current_users Chatrooms. I've already been able to pull the chatrooms associated with a current user as well as the last message delivered in those chatrooms. I tried the following but this only gave me the

ActionCable: How to use dynamic channels

人走茶凉 提交于 2020-01-01 06:45:42
问题 I have built a simple chat with Rails 5 and ActionCable where i have one simple "chat" channel. How can i make the channel subscription and message broadcasting dynamic, so i can create chat channels and have the messages go to the right channels? I cannot find a single code example of this unfortunately. Update The answer below is correct. I also found it now mentioned in the rails guide. Don't think it was there before http://edgeguides.rubyonrails.org/action_cable_overview.html#client

ActionCable Not Receiving Data

梦想的初衷 提交于 2020-01-01 01:18:07
问题 I created the following using ActionCable but not able to receive any data that is being broadcasted. Comments Channel : class CommentsChannel < ApplicationCable::Channel def subscribed comment = Comment.find(params[:id]) stream_for comment end end JavaScript : var cable = Cable.createConsumer('ws://localhost:3000/cable'); var subscription = cable.subscriptions.create({ channel: "CommentsChannel", id: 1 },{ received: function(data) { console.log("Received data") } }); It connects fine and I

How to send a pong in response to ping; Reactjs & Rails Action Cable?

扶醉桌前 提交于 2019-12-31 06:24:59
问题 I am trying to send a heartbeat pong response to a ping in Websocket connections in my project using reactjs front end with the actioncable module and a Rails backend with Action Cable, but I cannot get the backend to recognize a pong response. I have gotten to the point where, after receiving a ping message through the websocket 'onmessage' listener, and I can get the backend to receive my response but it cannot process the response as a pong to the ping since it appears the backend does not

ActionCable - how to display number of connected users?

放肆的年华 提交于 2019-12-28 05:51:41
问题 I'm trying to create a simple chat-like application (planning poker app) with Action Cable. I'm a little bit confused by the terminology, files hierarchy and how the callbacks work. This is the action that creates user session: class SessionsController < ApplicationController def create cookies.signed[:username] = params[:session][:username] redirect_to votes_path end end A user can then post a vote that should be broadcasted to everyone: class VotesController < ApplicationController def

Rails 5.2 app, with angular as Front end not able to run on local to make a call for action cable

泄露秘密 提交于 2019-12-25 03:34:15
问题 I am running a rails 5 app(action cable), angular is also used in Front-end. Getting below error when angularJS tries to send request to rails server via /cable Started GET "/cable" for 127.0.0.1 at 2019-01-09 18:37:05 +0530 Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2019-01-09 18:37:05 +0530 Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket) Exiting /home/testt/.rvm/gems/ruby-2.4.4@testt/gems/redis-3.3.5/lib/redis/connection

Cannot access data from ActionCable on React front-end

余生颓废 提交于 2019-12-25 02:54:07
问题 I am trying to broadcast Messages that belong to a certain Game from a rails backend using actioncable. In my messages_controller: def create @game = Game.find(message_params[:game_id]) @message = Message.new(message_params) if @message.save serialized_data = ActiveModelSerializers::Adapter::Json.new( MessageSerializer.new(@message) ).serializable_hash MessagesChannel.broadcast_to @game, serialized_data head :ok end end In my messages_channel: def subscribed @game = Game.find(params[:id][