Class: GameOverseer::InputHandler
- Inherits:
-
Object
- Object
- GameOverseer::InputHandler
- Defined in:
- lib/gameoverseer/input_handler/input_handler.rb
Class Method Summary collapse
-
.data_valid? ⇒ Boolean
Checks if hash contains ‘channel’ and ‘mode’.
-
.forward_to_channel_manager ⇒ Object
Sends data and client_id to ChannelManager.
- .process_data(client_id, data) ⇒ Object
Class Method Details
.data_valid? ⇒ Boolean
Checks if hash contains ‘channel’ and ‘mode’
14 15 16 17 18 19 20 |
# File 'lib/gameoverseer/input_handler/input_handler.rb', line 14 def self.data_valid? if @data["channel"] if @data["mode"] true end end end |
.forward_to_channel_manager ⇒ Object
Sends data and client_id to ChannelManager
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gameoverseer/input_handler/input_handler.rb', line 23 def self.forward_to_channel_manager count = 0 begin channel_manager = GameOverseer::ChannelManager.instance channel_manager.send_to_service(@client_id, @data) rescue NoMethodError => e GameOverseer::Console.log("InputHandler> #{e.to_s}") raise if count >=2 count+=1 retry unless count >= 2 end end |
.process_data(client_id, data) ⇒ Object
6 7 8 9 10 |
# File 'lib/gameoverseer/input_handler/input_handler.rb', line 6 def self.process_data(client_id, data) @data = data @client_id = client_id forward_to_channel_manager if data_valid? end |