Class: Intervention::Server
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Intervention::Server
- Defined in:
- lib/intervention/server.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(*args, **kwargs, &block) ⇒ Server
constructor
A new instance of Server.
- #inspect ⇒ Object
- #on_message_complete(parser) ⇒ Object
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(*args, **kwargs, &block) ⇒ Server
Returns a new instance of Server.
9 10 11 12 |
# File 'lib/intervention/server.rb', line 9 def initialize *args, **kwargs, &block super @client = kwargs[:client] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/intervention/server.rb', line 3 def client @client end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
3 4 5 |
# File 'lib/intervention/server.rb', line 3 def parser @parser end |
Instance Method Details
#inspect ⇒ Object
5 6 7 |
# File 'lib/intervention/server.rb', line 5 def inspect "#<Server:%s host:%s port:%s>" % [(object_id << 1).to_s(16), Intervention.config.host_address, Intervention.config.host_port] end |
#on_message_complete(parser) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/intervention/server.rb', line 23 def parser callback :response @client.send_data @parser.raw_data @client.close_connection_after_writing self.close_connection Intervention.servers.delete self end |
#post_init ⇒ Object
14 15 16 17 |
# File 'lib/intervention/server.rb', line 14 def post_init Intervention.servers << self @parser = Segregate.new(self, debug: true) end |
#receive_data(data) ⇒ Object
19 20 21 |
# File 'lib/intervention/server.rb', line 19 def receive_data data @parser.parse_data data end |
#unbind ⇒ Object
32 33 34 35 |
# File 'lib/intervention/server.rb', line 32 def unbind @client.close_connection_after_writing if @client self.close_connection end |