Esempio n. 1
0
 def _serve_client(self, sock, credentials):
     h, p = sock.getpeername()
     self.logger.info("welcome %s:%s", h, p)
     try:
         config = dict(self.protocol_config, credentials = credentials)
         conn = Connection(self.service, Channel(SocketStream(sock)), 
             config = config, _lazy = True)
         conn._init_service()
         conn.serve_all()
     finally:
         self.logger.info("goodbye %s:%s", h, p)
Esempio n. 2
0
 def _serve_client(self, sock, credentials):
     h, p = sock.getpeername()
     self.logger.info("welcome %s:%s", h, p)
     try:
         config = dict(self.protocol_config, credentials=credentials)
         conn = Connection(self.service,
                           Channel(SocketStream(sock)),
                           config=config,
                           _lazy=True)
         conn._init_service()
         conn.serve_all()
     finally:
         self.logger.info("goodbye %s:%s", h, p)
Esempio n. 3
0
 def _serve_client(self, sock, credentials):
     addrinfo = sock.getpeername()
     if credentials:
         self.logger.info("welcome %s (%r)", addrinfo, credentials)
     else:
         self.logger.info("welcome %s", addrinfo)
     try:
         config = dict(self.protocol_config, credentials = credentials, 
             endpoints = (sock.getsockname(), addrinfo))
         conn = Connection(self.service, Channel(SocketStream(sock)),
             config = config, _lazy = True)
         conn._init_service()
         conn.serve_all()
     finally:
         self.logger.info("goodbye %s", addrinfo)
Esempio n. 4
0
 def _serve_client(self, sock, credentials):
     addrinfo = sock.getpeername()
     h = addrinfo[0]
     p = addrinfo[1]
     if credentials:
         self.logger.info("welcome [%s]:%s (%r)", h, p, credentials)
     else:
         self.logger.info("welcome [%s]:%s", h, p)
     try:
         config = dict(self.protocol_config, credentials = credentials)
         conn = Connection(self.service, Channel(SocketStream(sock)),
             config = config, _lazy = True)
         conn._init_service()
         conn.serve_all()
     finally:
         self.logger.info("goodbye [%s]:%s", h, p)
Esempio n. 5
0
 def _serve_client(self, sock, credentials):
     addrinfo = sock.getpeername()
     h = addrinfo[0]
     p = addrinfo[1]
     if credentials:
         self.logger.info("welcome [%s]:%s (%r)", h, p, credentials)
     else:
         self.logger.info("welcome [%s]:%s", h, p)
     try:
         config = dict(self.protocol_config, credentials = credentials, 
             endpoints = (sock.getsockname(), addrinfo), logger = self.logger)
         conn = Connection(self.service, Channel(SocketStream(sock)),
             config = config, _lazy = True)
         conn._init_service()
         conn.serve_all()
     finally:
         self.logger.info("goodbye [%s]:%s", h, p)
Esempio n. 6
0
class RPyCProtocol(protocol.Protocol):
    """
    RPyC twisted protocol - feeds data into a TwistedSocketStream instance
    which is read out by RPyC.performing
    """
    def __init__(self, service):
        self.service = service

    def connectionMade(self):
        self._sockstream = TwistedSocketStream(self)
        self._channel = Channel(self._sockstream)
        self._connection = Connection(self.service, self._channel, _lazy=True)
        self._connection._init_service()

    def connectionLost(self, reason):
        if hasattr(self, "_connection"):
            self._connection.close()

    def dataReceived(self, data):
        # Spoof synchronous incoming data:
        self._sockstream.dataReceived(data)
        # Do the rest of our processing in a separate thread so
        # we don't block the reactor:
        threads.deferToThread(self._connection.serve, 1)