You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
"""
|
|
Handles the acc_ready event. Accept as long as possible on subject.
|
|
For each successfull accept assign protocol and emit a new_con event
|
|
holding the new connection.
|
|
|
|
Author: Georg Hopp <ghopp@spamtitan.com>
|
|
"""
|
|
|
|
from Connection import Connection
|
|
from ConnectEntryPoint import ConnectEntryPoint
|
|
|
|
from Event.EventHandler import EventHandler
|
|
from Transport import Transport
|
|
|
|
class Connector(EventHandler):
|
|
def __init__(self):
|
|
super(Connector, self).__init__()
|
|
|
|
self._event_methods = {
|
|
ConnectEntryPoint.eventId('acc_ready') : self._accept
|
|
}
|
|
|
|
def _accept(self, event):
|
|
try:
|
|
protocol = event.subject.getProtocol()
|
|
if event.subject.accept():
|
|
con = event.subject.pop()
|
|
while con:
|
|
new_con = Connection(con, protocol)
|
|
self.issueEvent(new_con, 'new_con')
|
|
con = event.subject.pop()
|
|
except Transport.Error as error:
|
|
self.issueEvent(event.subject, 'close')
|
|
|
|
return True
|
|
|
|
# vim: set ft=python et ts=8 sw=4 sts=4:
|