Sha256: 5de156039710826b7c04df5125189e39ce2749996c5d09b0601eddfd6ab9ca27
Contents?: true
Size: 1.09 KB
Versions: 21
Compression:
Stored size: 1.09 KB
Contents
module ApplicationCable class Channel < ActionCable::Channel::Base; end class Connection < ActionCable::Connection::Base; end end module Hyperloop class ActionCableChannel < ApplicationCable::Channel class << self def subscriptions @subscriptions ||= Hash.new { |h, k| h[k] = 0 } end end def inc_subscription self.class.subscriptions[params[:hyperloop_channel]] = self.class.subscriptions[params[:hyperloop_channel]] + 1 end def dec_subscription self.class.subscriptions[params[:hyperloop_channel]] = self.class.subscriptions[params[:hyperloop_channel]] - 1 end def subscribed session_id = params["client_id"] authorization = Hyperloop.authorization(params["salt"], params["hyperloop_channel"], session_id) if params["authorization"] == authorization inc_subscription stream_from "hyperloop-#{params[:hyperloop_channel]}" else reject end end def unsubscribed Hyperloop::Connection.disconnect(params[:hyperloop_channel]) if dec_subscription == 0 end end end
Version data entries
21 entries across 21 versions & 1 rubygems