Class: Coronet::Listener
- Inherits:
-
GServer
- Object
- GServer
- Coronet::Listener
- Defined in:
- lib/coronet/listener.rb
Instance Attribute Summary collapse
-
#mediator_klass ⇒ Object
Returns the value of attribute mediator_klass.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
Instance Method Summary collapse
-
#initialize(port, protocol) ⇒ Listener
constructor
, mediator_klass) #callback=nil).
- #serve(io) ⇒ Object
- #uses_mediator_class(mediator_klass) ⇒ Object
Constructor Details
#initialize(port, protocol) ⇒ Listener
, mediator_klass) #callback=nil)
7 8 9 10 11 |
# File 'lib/coronet/listener.rb', line 7 def initialize(port, protocol) #, mediator_klass) #callback=nil) @port = port @protocol = protocol super(port) end |
Instance Attribute Details
#mediator_klass ⇒ Object
Returns the value of attribute mediator_klass.
5 6 7 |
# File 'lib/coronet/listener.rb', line 5 def mediator_klass @mediator_klass end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/coronet/listener.rb', line 3 def port @port end |
#protocol ⇒ Object
Returns the value of attribute protocol.
4 5 6 |
# File 'lib/coronet/listener.rb', line 4 def protocol @protocol end |
Instance Method Details
#serve(io) ⇒ Object
15 16 17 18 19 |
# File 'lib/coronet/listener.rb', line 15 def serve(io) request = @protocol.read(io) response = @mediator_klass.handle(request) @protocol.write(response, io) end |
#uses_mediator_class(mediator_klass) ⇒ Object
13 |
# File 'lib/coronet/listener.rb', line 13 def uses_mediator_class(mediator_klass); @mediator_klass = mediator_klass; end |