On 06.03.2006, at 22:02, peter royal wrote:
On Mar 6, 2006, at 3:49 PM, Simon Raess wrote:
On the client side, it is possible to specify a separate IoHandler
for each session. Wouldn't it be more natural to have the
possibility to store state in the handler itself? On the server,
this would require to have a separate IoHandler for each session.
What do you think?
This can certainly be achieved with the current architecture.. What
you will want is an IoHandler that creates a delegate every time a
new session is established on the server-side, and then the
delegate would just forward events as necessary to the delegate.
-pete
Yes, I didn't think about that possibility. But why not have
something like the following:
IoAcceptor acceptor = ...;
IoHandlerFactory factory = ...;
acceptor.accept(address, factory);
where IoHandlerFactory is an interface that has the responsibility to
create IoHandlers. This factory would be used by the acceptor to
create an IoHandler whenever a new session is accepted.
This way, both the client-side and server-side IoHandler could safely
use state in instance variables. This seems more consistent to me.
Simon