class WebsocketRails::DataStore::Connection
The connection data store operates much like the {Controller} store. The biggest difference is that the data placed inside is private for individual users and accessible from any controller. Anything placed inside the connection data store will be deleted when a user disconnects.
The connection data store is accessed through the `#connection_store` instance method inside your controller.
If we were writing a basic chat system, we could use the connection data store to hold onto a user's current screen name.
class UserController < WebsocketRails::BaseController def set_screen_name connection_store[:screen_name] = message[:screen_name] end end class ChatController < WebsocketRails::BaseController def say_hello screen_name = connection_store[:screen_name] send_message :new_message, "#{screen_name} says hello" end end
Attributes
connection[RW]
Public Class Methods
new(connection)
click to toggle source
Calls superclass method
WebsocketRails::DataStore::Base::new
# File lib/websocket_rails/data_store.rb, line 89 def initialize(connection) super() @connection = connection end