Say I have a server that I want multiple protocol handlers for, but
only one instance of the core server can be running since it keeps
state. So I want multiple tcp servers running different protocols all
accepting requests and then funneling them into the core server,
getting back a response, and sending the response to the client.
Would something like the following work? Where for instance in the
protocol handler I could call @app.process_request(data). It''s the
only thing I can think of off the top of my head.
app = Application.new
EventMachine::start_server(host, port, Protocol::Netstring) {|s|
s.instance_eval { @app=app}
}
EventMachine::start_server(host, port, Protocol::Http) {|s|
s.instance_eval { @app=app}
}
Francis Cianfrocca
2006-Oct-27 04:23 UTC
[Eventmachine-talk] protocol handler implementation
On 10/27/06, snacktime <snacktime at gmail.com> wrote:> > Say I have a server that I want multiple protocol handlers for, but > only one instance of the core server can be running since it keeps > state. So I want multiple tcp servers running different protocols all > accepting requests and then funneling them into the core server, > getting back a response, and sending the response to the client. > > Would something like the following work? Where for instance in the > protocol handler I could call @app.process_request(data). It''s the > only thing I can think of off the top of my head. > > app = Application.new > > EventMachine::start_server(host, port, Protocol::Netstring) {|s| > s.instance_eval { @app=app} > } > EventMachine::start_server(host, port, Protocol::Http) {|s| > s.instance_eval { @app=app} > } > _______________________________________________I do stuff like that all the time. It looks ugly but it''s not as bad as using a global. :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20061027/6bf5830c/attachment.html