Commit e66209ba authored by Vincent Pelletier's avatar Vincent Pelletier

Move ServerConnection instanciation to connection.py, as it is done inconditionally.

Make connection.py call connectionAccepted with the new connection as parameter.
Change connectionAccepted prototype, as fewer parameters are needed now that "conn" contains them.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1169 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 80ef47b5
......@@ -150,7 +150,10 @@ class ListeningConnection(BaseConnection):
try:
new_s, addr = self.connector.getNewConnection()
logging.debug('accepted a connection from %s:%d', *addr)
self.handler.connectionAccepted(self, new_s, addr)
handler = self.getHandler()
new_conn = ServerConnection(self.getEventManager(), handler,
connector=new_s, addr=addr)
handler.connectionAccepted(new_conn)
except ConnectorTryAgainException:
pass
......
......@@ -134,13 +134,10 @@ class EventHandler(object):
"""Called when a connection failed."""
logging.debug('connection failed for %s:%d', *(conn.getAddress()))
def connectionAccepted(self, conn, connector, addr):
def connectionAccepted(self, conn):
"""Called when a connection is accepted."""
logging.debug('connection accepted from %s:%d', *addr)
new_conn = ServerConnection(conn.getEventManager(), conn.getHandler(),
connector=connector, addr=addr)
# A request for a node identification should arrive.
new_conn.expectMessage(timeout = 10, additional_timeout = 0)
conn.expectMessage(timeout = 10, additional_timeout = 0)
def timeoutExpired(self, conn):
"""Called when a timeout event occurs."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment