Class: ChannelHandler

Inherits:
SockJS::Session
  • Object
show all
Defined in:
lib/volt/server/channel_handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, *args) ⇒ ChannelHandler

Returns a new instance of ChannelHandler.



12
13
14
15
16
17
18
19
# File 'lib/volt/server/channel_handler.rb', line 12

def initialize(session, *args)
  @session = session

  @@channels ||= []
  @@channels << self
  
  super
end

Class Method Details

.message_allObject



5
6
7
8
9
10
# File 'lib/volt/server/channel_handler.rb', line 5

def self.message_all
  @@channels.each do |channel|
    channel.send(message)
  end
  
end

Instance Method Details

#closedObject



26
27
28
29
# File 'lib/volt/server/channel_handler.rb', line 26

def closed    
  # Remove ourself from the available channels
  @@channels.delete(self)
end

#process_message(message) ⇒ Object



21
22
23
24
# File 'lib/volt/server/channel_handler.rb', line 21

def process_message(message)
  puts "Process: #{message}"
  self.class.message_all(message)
end