Exemplo n.º 1
0
 def connectionMade(self):
     log.debug('slavepp', 'connectionMade')
     protocol = self._server.buildProtocol(None)
     protocol.transport = MyTransport(self.transport, self._childWriteFd)
     # FIXME: need to get a transport in here, like Broker
     log.debug('slavepp', 'protocol %r, transport %r',
         protocol, protocol.transport)
     self._protocol = protocol
     protocol.connectionMade()
Exemplo n.º 2
0
 def test_wrapProtocol(self):
     """
     L{wrapProtocol}, when passed a L{Protocol} should return something that
     has write(), writeSequence(), loseConnection() methods which call the
     Protocol's dataReceived() and connectionLost() methods, respectively.
     """
     protocol = MockProtocol()
     protocol.transport = StubTransport()
     protocol.connectionMade()
     wrapped = session.wrapProtocol(protocol)
     wrapped.dataReceived('dataReceived')
     self.assertEquals(protocol.transport.buf, 'dataReceived')
     wrapped.write('data')
     wrapped.writeSequence(['1', '2'])
     wrapped.loseConnection()
     self.assertEquals(protocol.data, 'data12')
     protocol.reason.trap(error.ConnectionDone)
 def test_wrapProtocol(self):
     """
     L{wrapProtocol}, when passed a L{Protocol} should return something that
     has write(), writeSequence(), loseConnection() methods which call the
     Protocol's dataReceived() and connectionLost() methods, respectively.
     """
     protocol = MockProtocol()
     protocol.transport = StubTransport()
     protocol.connectionMade()
     wrapped = session.wrapProtocol(protocol)
     wrapped.dataReceived(b"dataReceived")
     self.assertEqual(protocol.transport.buf, b"dataReceived")
     wrapped.write(b"data")
     wrapped.writeSequence([b"1", b"2"])
     wrapped.loseConnection()
     self.assertEqual(protocol.data, b"data12")
     protocol.reason.trap(error.ConnectionDone)
Exemplo n.º 4
0
    def addProtocolFactory(self, deferred, canceller, protocolFactory):
        if canceller.cancelled:
            return None

        protocol = protocolFactory.buildProtocol(self._address)
        log.msg('EpicsSubscriptionProtocol: addProtocolFactory: Append %(p)s (length: %(l)d+1)', p=protocol, l=len(self._protocols), logLevel=_DEBUG)
        self._protocols.append(protocol)
        deferred.callback(protocol)

        if self.transport is not None:
            transport = EpicsSubscriptionTransport(self.transport, protocol, self)
            log.msg('EpicsSubscriptionProtocol: addProtocolFactory: Connected so call makeConnection %(t)s', t=transport, logLevel=_TRACE)
            protocol.makeConnection(transport)
            if self._connected:
                protocol.connectionMade()
                if self._data is not None:
                    protocol.dataReceived(self._data)

        else:
            log.msg('EpicsSubscriptionProtocol: addProtocolFactory: Not connected so do NOT call makeConnection', logLevel=_TRACE)
    
        return protocol
Exemplo n.º 5
0
 def connectionMade(self):
     self._connected = True
     log.msg('DistributingProtocol: connectionMade: Log connection established', logLevel=_TRACE)
     for protocol in self._protocols:
         log.msg('DistributingProtocol: makeConnection: Distribute to %(p)s', p=protocol, logLevel=_TRACE)
         protocol.connectionMade()
Exemplo n.º 6
0
 def connectionMade(self):
     log.info('Process %s has started.'%self.process_name)
     for protocol in self.stdout_protocol, self.stderr_protocol, self.stdin_protocol:
         protocol.connectionMade()