2014-03-10 21:36:47 +00:00
|
|
|
from __future__ import absolute_import
|
2014-03-10 20:57:50 +00:00
|
|
|
from . import http, tcp
|
|
|
|
|
|
|
|
protocols = {
|
|
|
|
'http': dict(handler=http.HTTPHandler, flow=http.HTTPFlow),
|
|
|
|
'tcp': dict(handler=tcp.TCPHandler)
|
2014-05-15 16:16:42 +00:00
|
|
|
}
|
2014-03-10 20:57:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
def _handler(conntype, connection_handler):
|
|
|
|
if conntype in protocols:
|
|
|
|
return protocols[conntype]["handler"](connection_handler)
|
|
|
|
|
|
|
|
raise NotImplementedError # pragma: nocover
|
|
|
|
|
|
|
|
|
|
|
|
def handle_messages(conntype, connection_handler):
|
|
|
|
return _handler(conntype, connection_handler).handle_messages()
|
|
|
|
|
|
|
|
|
|
|
|
def handle_error(conntype, connection_handler, error):
|
|
|
|
return _handler(conntype, connection_handler).handle_error(error)
|