Class: ProconBypassMan::ExternalInput::Channels::TCPIPChannel::AppServer
- Inherits:
-
SimpleTCPServer
- Object
- SimpleTCPServer
- ProconBypassMan::ExternalInput::Channels::TCPIPChannel::AppServer
- Defined in:
- lib/procon_bypass_man/external_input/channels/tcpip_channel.rb
Class Attribute Summary collapse
-
.command_queue ⇒ Object
Returns the value of attribute command_queue.
Instance Method Summary collapse
Methods inherited from SimpleTCPServer
#connections_size, #initialize, #run, #shutdown, #start_server
Constructor Details
This class inherits a constructor from SimpleTCPServer
Class Attribute Details
.command_queue ⇒ Object
Returns the value of attribute command_queue.
11 12 13 |
# File 'lib/procon_bypass_man/external_input/channels/tcpip_channel.rb', line 11 def command_queue @command_queue end |
Instance Method Details
#post_init ⇒ Object
14 15 16 |
# File 'lib/procon_bypass_man/external_input/channels/tcpip_channel.rb', line 14 def post_init ProconBypassMan.logger.info { "[ExternalInput][TCPIPChannel] A client has connected" } end |
#receive_data(client, data) ⇒ String
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/procon_bypass_man/external_input/channels/tcpip_channel.rb', line 23 def receive_data(client, data) case data when /^{/ self.class.command_queue.push(data) client.write("OK\n") return when /^\n/ if self.class.command_queue.empty? client.write("EMPTY\n") return end data = self.class.command_queue.pop client.write("#{data}\n") return else client.write("Unknown command\n") return end end |
#unbind ⇒ Object
18 19 20 |
# File 'lib/procon_bypass_man/external_input/channels/tcpip_channel.rb', line 18 def unbind ProconBypassMan.logger.info { "[ExternalInput][TCPIPChannel] A client has disconnected" } end |