Class: Evma::TcpServerFactory

Inherits:
ProtocolFactory show all
Defined in:
lib/evma/factory.rb

Instance Attribute Summary

Attributes inherited from Protocol

#signature

Instance Method Summary collapse

Methods inherited from Protocol

#close, #close_after_writing, #unbind

Constructor Details

#initialize(server, port, protocol_handler = Evma::Protocol) ⇒ TcpServerFactory

Returns a new instance of TcpServerFactory.



62
63
64
65
66
67
68
# File 'lib/evma/factory.rb', line 62

def initialize server, port, protocol_handler = Evma::Protocol
  Evma::Reactor.instance # ensure initialization
  sig = EventMachine.start_tcp_server server, port
  super sig
  @protocol_handler = protocol_handler
  Evma::Container.store self
end

Instance Method Details

#accept(new_obj) ⇒ Object



70
71
72
73
# File 'lib/evma/factory.rb', line 70

def accept new_obj
  # don't bother calling Evma::Reactor.instance, since only Reactor can call accept
  Evma::Container.store @protocol_handler.new( new_obj )
end