Sha256: 491bcc2b877a59450430025eaba6c6549cfa68b3699efda4cd0604f03f291722

Contents?: true

Size: 916 Bytes

Versions: 9

Compression:

Stored size: 916 Bytes

Contents

class ChatController < WebsocketRails::BaseController

  before_action do
    if message_counter > 10
      self.message_counter = 0
    end
  end

  before_action :only => :new_message do
    true
  end

  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

9 entries across 9 versions & 3 rubygems

Version Path
hkroger-websocket-rails-0.7.1 spec/dummy/app/controllers/chat_controller.rb
wwl-websocket-rails-0.7.3 spec/dummy/app/controllers/chat_controller.rb
wwl-websocket-rails-0.7.2 spec/dummy/app/controllers/chat_controller.rb
wwl-websocket-rails-0.7.1 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.7.0 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.6.2 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.6.1 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.6.0 spec/dummy/app/controllers/chat_controller.rb
websocket-rails-0.5.0 spec/dummy/app/controllers/chat_controller.rb