aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/app/assets
diff options
context:
space:
mode:
authorMick Staugaard <mick@staugaard.com>2018-10-11 13:47:16 -0700
committerMick Staugaard <mick@staugaard.com>2018-12-05 10:40:29 -0800
commit58dbc1c2ed0e372d9cae4c9e3baebb679a726dc3 (patch)
tree9cfd085ce218a95879df56e8008d54978026e134 /actioncable/app/assets
parentb802e08273f899d5f3b199f7c6a4f5d514c1b0e1 (diff)
downloadrails-58dbc1c2ed0e372d9cae4c9e3baebb679a726dc3.tar.gz
rails-58dbc1c2ed0e372d9cae4c9e3baebb679a726dc3.tar.bz2
rails-58dbc1c2ed0e372d9cae4c9e3baebb679a726dc3.zip
Stop trying to reconnect on unauthorized cable connections
Diffstat (limited to 'actioncable/app/assets')
-rw-r--r--actioncable/app/assets/javascripts/action_cable.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable.js b/actioncable/app/assets/javascripts/action_cable.js
index ee11c62eb6..65e32d6c3f 100644
--- a/actioncable/app/assets/javascripts/action_cable.js
+++ b/actioncable/app/assets/javascripts/action_cable.js
@@ -136,10 +136,16 @@
var INTERNAL = {
message_types: {
welcome: "welcome",
+ disconnect: "disconnect",
ping: "ping",
confirmation: "confirm_subscription",
rejection: "reject_subscription"
},
+ disconnect_reasons: {
+ unauthorized: "unauthorized",
+ invalid_request: "invalid_request",
+ server_restart: "server_restart"
+ },
default_mount_path: "/cable",
protocols: [ "actioncable-v1-json", "actioncable-unsupported" ]
};
@@ -251,12 +257,18 @@
if (!this.isProtocolSupported()) {
return;
}
- var _JSON$parse = JSON.parse(event.data), identifier = _JSON$parse.identifier, message = _JSON$parse.message, type = _JSON$parse.type;
+ var _JSON$parse = JSON.parse(event.data), identifier = _JSON$parse.identifier, message = _JSON$parse.message, reason = _JSON$parse.reason, reconnect = _JSON$parse.reconnect, type = _JSON$parse.type;
switch (type) {
case message_types.welcome:
this.monitor.recordConnect();
return this.subscriptions.reload();
+ case message_types.disconnect:
+ logger.log("Disconnecting. Reason: " + reason);
+ return this.close({
+ allowReconnect: reconnect
+ });
+
case message_types.ping:
return this.monitor.recordPing();