Class: Coronet::Listener

Inherits:
GServer
  • Object
show all
Defined in:
lib/coronet/listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_klassObject

Returns the value of attribute mediator_klass.



5
6
7
# File 'lib/coronet/listener.rb', line 5

def mediator_klass
  @mediator_klass
end

#portObject

Returns the value of attribute port.



3
4
5
# File 'lib/coronet/listener.rb', line 3

def port
  @port
end

#protocolObject

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