module WebsocketRails

Constants

VERSION

Public Class Methods

[](channel) click to toggle source
# File lib/websocket_rails/channel_manager.rb, line 11
def [](channel)
  channel_manager[channel]
end
channel_manager() click to toggle source
# File lib/websocket_rails/channel_manager.rb, line 7
def channel_manager
  @channel_manager ||= ChannelManager.new
end
channel_tokens() click to toggle source
# File lib/websocket_rails/channel_manager.rb, line 15
def channel_tokens
  channel_manager.channel_tokens
end
config() click to toggle source
# File lib/websocket-rails.rb, line 12
def config
  @config ||= Configuration.new
end
filtered_channels() click to toggle source
# File lib/websocket_rails/channel_manager.rb, line 19
def filtered_channels
  channel_manager.filtered_channels
end
logger() click to toggle source
# File lib/websocket-rails.rb, line 24
def logger
  config.logger
end
setup() { |config| ... } click to toggle source
# File lib/websocket-rails.rb, line 8
def setup
  yield config
end
standalone?() click to toggle source
# File lib/websocket-rails.rb, line 20
def standalone?
  config.standalone == true
end
synchronize?() click to toggle source
# File lib/websocket-rails.rb, line 16
def synchronize?
  config.synchronize == true || config.standalone == true
end
users() click to toggle source

Contains a Hash of all connected users. This can be used to trigger an event on a specific user from outside of a WebsocketRails controller.

The key for a particular user is defined in the configuration as `config.user_identifier`.

If there is a `current_user` method defined in ApplicationController and a user is signed in to your application when the connection is opened, WebsocketRails will call the method defined in `config.user_identifier` on the `current_user` object and use that value as the key.

# In your events.rb file
WebsocketRails.setup do |config|
  # Defaults to :id
  config.user_identifier = :name
end

# In a standard controller or background job
name = current_user.name
WebsocketRails.users[name].send_message :event_name, data

If no `current_user` method is defined or the user is not signed in when the WebsocketRails connection is opened, the connection will not be stored in the UserManager.

# File lib/websocket_rails/user_manager.rb, line 32
def self.users
  @user_manager ||= UserManager.new
end