Sha256: d9a18e9ce54c15c56671d175f7697cd668dec403cdb1808e8678c09453ec85fc

Contents?: true

Size: 804 Bytes

Versions: 8

Compression:

Stored size: 804 Bytes

Contents

module WebsocketRails
  class InternalEvents
    def self.events
      Proc.new do
        namespace :websocket_rails do
          subscribe :pong, :to => InternalController, :with_method => :do_pong
          subscribe :subscribe, :to => InternalController, :with_method => :subscribe_to_channel
        end
      end
    end
  end

  class InternalController < BaseController
    include Logging

    def subscribe_to_channel
      channel_name = event.data[:channel]
      unless WebsocketRails[channel_name].is_private?
        WebsocketRails[channel_name].subscribe connection
        trigger_success
      else
        trigger_failure( { :reason => "channel is private", :hint => "use subscibe_private instead." } )
      end
    end

    def do_pong
      connection.pong = true
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
websocket-rails-0.4.7 lib/websocket_rails/internal_events.rb
websocket-rails-0.4.6 lib/websocket_rails/internal_events.rb
websocket-rails-0.4.5 lib/websocket_rails/internal_events.rb
websocket-rails-0.4.4 lib/websocket_rails/internal_events.rb
websocket-rails-0.4.3 lib/websocket_rails/internal_events.rb
websocket-rails-0.4.2 lib/websocket_rails/internal_events.rb
websocket-rails-0.4.1 lib/websocket_rails/internal_events.rb
websocket-rails-0.4.0 lib/websocket_rails/internal_events.rb