Sha256: f6ba337f556beb3d3bec93f1c617181796a5b5df2b8b59ccd71d62ddf2fcc046

Contents?: true

Size: 912 Bytes

Versions: 10

Compression:

Stored size: 912 Bytes

Contents

class ChatController < WebsocketRails::BaseController

  observe {
    if message_counter > 10
      self.message_counter = 0
    end
  }
  
  observe(:new_message) {
    true
  }
  
  attr_accessor :message_counter

  def initialize
    # perform application setup here
    @message_counter = 0
  end
  
  def client_connected
    # do something when a client connects
  end
  
  def error_occurred
    # do something when an error occurs
  end
    
  def new_message
    @message_counter += 1
    broadcast_message :new_message, message
  end
  
  def new_user
    controller_store[:user] = message
    broadcast_user_list
  end
  
  def change_username
    controller_store[:user] = message
    broadcast_user_list
  end
  
  def delete_user
    controller_store[:user] = nil
    broadcast_user_list
  end
  
  def broadcast_user_list
    users = ['user']
    broadcast_message :user_list, users
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
websocket-rails-0.4.9 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.8 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.7 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.6 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.5 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.4 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.3 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.2 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.1 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.4.0 spec/dummy/app/controllers/chat_controller.rb