actioncable

Action Cable: How to deliver missed chat messages

扶醉桌前 提交于 2020-08-07 05:35:11
问题 What's a good way to deliver missed messages in a chat for instance with Action Cable? Like when you close the laptop and open it again, you are not reloading the page but you may have missed messages One way would be to do an AJAX call instead using Action Cable but then i would have to duplicate some of the logic that happens when you receive a message. I would like to just reuse Action Cable if possible 回答1: Store them in the database of course. And load them from the database each time

Action Cable: How to deliver missed chat messages

坚强是说给别人听的谎言 提交于 2020-08-07 05:29:43
问题 What's a good way to deliver missed messages in a chat for instance with Action Cable? Like when you close the laptop and open it again, you are not reloading the page but you may have missed messages One way would be to do an AJAX call instead using Action Cable but then i would have to duplicate some of the logic that happens when you receive a message. I would like to just reuse Action Cable if possible 回答1: Store them in the database of course. And load them from the database each time

Action Cable: How to deliver missed chat messages

本小妞迷上赌 提交于 2020-08-07 05:29:32
问题 What's a good way to deliver missed messages in a chat for instance with Action Cable? Like when you close the laptop and open it again, you are not reloading the page but you may have missed messages One way would be to do an AJAX call instead using Action Cable but then i would have to duplicate some of the logic that happens when you receive a message. I would like to just reuse Action Cable if possible 回答1: Store them in the database of course. And load them from the database each time

How can I test ActionCable using RSpec?

心已入冬 提交于 2020-02-06 07:34:11
问题 This is my NotificationChannel class NotificationChannel < ApplicationCable::Channel def subscribed stream_from "notification_user_#{user.id}" end def unsubscribed stop_all_streams end end How can I write test for this ActionCable channels This is my Rspec require 'rails_helper' require_relative 'stubs/test_connection' RSpec.describe NotificationChannel, type: :channel do before do @user = create(:user) @connection = TestConnection.new(@user) @channel = NotificationChannel.new @connection, {}

Detect Action Cable connection status

回眸只為那壹抹淺笑 提交于 2020-01-24 14:06:06
问题 I have a Vue app that connects to a Rails back-end and need to find out whether the connection is established or not. In my app I do: var app = new Vue({ name: "Site", store, router, i18n, components: {}, mixins: [], data: { cable: App.cable } }); However cable.connection.disconnected is always true even when actually connected. How can I reliably figure out (when needed) what the connection status is? 回答1: Got it sorted out. In my components, when I need to find out cable status, I do this.

Detect Action Cable connection status

自古美人都是妖i 提交于 2020-01-24 14:03:02
问题 I have a Vue app that connects to a Rails back-end and need to find out whether the connection is established or not. In my app I do: var app = new Vue({ name: "Site", store, router, i18n, components: {}, mixins: [], data: { cable: App.cable } }); However cable.connection.disconnected is always true even when actually connected. How can I reliably figure out (when needed) what the connection status is? 回答1: Got it sorted out. In my components, when I need to find out cable status, I do this.

Detect Action Cable connection status

匆匆过客 提交于 2020-01-24 14:02:07
问题 I have a Vue app that connects to a Rails back-end and need to find out whether the connection is established or not. In my app I do: var app = new Vue({ name: "Site", store, router, i18n, components: {}, mixins: [], data: { cable: App.cable } }); However cable.connection.disconnected is always true even when actually connected. How can I reliably figure out (when needed) what the connection status is? 回答1: Got it sorted out. In my components, when I need to find out cable status, I do this.

Rails ActionCable error during websocket handshake

拥有回忆 提交于 2020-01-24 04:00:20
问题 I'm trying to build a messaging app with Rails 5 ActionCable, but I'm getting the above error in the JS console. ws://localhost:3002/cable' failed: Error during WebSocket handshake: Unexpected response code: 404 I'm using the Redis and Puma gems. I have a Redis server running 7937:M 24 Jul 18:20:53.379 * The server is now ready to accept connections on port 6379 I start the Rails server with Puma: rails s Puma -p 3002 (is this even required?) config/cable.yml looks like this... development:

ActionCable on AWS: Error during WebSocket handshake: Unexpected response code: 404

狂风中的少年 提交于 2020-01-09 10:08:45
问题 We are attempting to deploy DHH's simple Rails 5 chat example to a single, self contained EC2 instance on AWS. Code is available here: https://github.com/HectorPerez/chat-in-rails5 We used Elastic Beanstalk to spin up a single instance thus: eb create dev-env -p “64bit Amazon Linux 2015.09 v2.0.4 running Ruby 2.2 (Puma)” –single -i t2.micro --envvars SECRET_KEY_BASE=g5dh9cg614a37d4bdece9126b42d50d0ab8b2fc785daa1e0dac0383d6387f36b This is a minimal installation, so there is no Elasticache, and

ActionCable on AWS: Error during WebSocket handshake: Unexpected response code: 404

别等时光非礼了梦想. 提交于 2020-01-09 10:08:44
问题 We are attempting to deploy DHH's simple Rails 5 chat example to a single, self contained EC2 instance on AWS. Code is available here: https://github.com/HectorPerez/chat-in-rails5 We used Elastic Beanstalk to spin up a single instance thus: eb create dev-env -p “64bit Amazon Linux 2015.09 v2.0.4 running Ruby 2.2 (Puma)” –single -i t2.micro --envvars SECRET_KEY_BASE=g5dh9cg614a37d4bdece9126b42d50d0ab8b2fc785daa1e0dac0383d6387f36b This is a minimal installation, so there is no Elasticache, and