当前位置: 首页>>代码示例>>Python>>正文


Python Protocol.makeConnection方法代码示例

本文整理汇总了Python中twisted.internet.protocol.Protocol.makeConnection方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.makeConnection方法的具体用法?Python Protocol.makeConnection怎么用?Python Protocol.makeConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.protocol.Protocol的用法示例。


在下文中一共展示了Protocol.makeConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
    def makeConnection(self, transport):
        """
        Connect this wrapper to the given transport and initialize the
        necessary L{OpenSSL.SSL.Connection} with a memory BIO.
        """
        tlsContext = self.factory._contextFactory.getContext()
        self._tlsConnection = Connection(tlsContext, None)
        if self.factory._isClient:
            self._tlsConnection.set_connect_state()
        else:
            self._tlsConnection.set_accept_state()
        self._appSendBuffer = []

        # Intentionally skip ProtocolWrapper.makeConnection - it might call
        # wrappedProtocol.makeConnection, which we want to make conditional.
        Protocol.makeConnection(self, transport)
        self.factory.registerProtocol(self)
        if self._connectWrapped:
            # Now that the TLS layer is initialized, notify the application of
            # the connection.
            ProtocolWrapper.makeConnection(self, transport)

        # Now that we ourselves have a transport (initialized by the
        # ProtocolWrapper.makeConnection call above), kick off the TLS
        # handshake.
        try:
            self._tlsConnection.do_handshake()
        except WantReadError:
            # This is the expected case - there's no data in the connection's
            # input buffer yet, so it won't be able to complete the whole
            # handshake now.  If this is the speak-first side of the
            # connection, then some bytes will be in the send buffer now; flush
            # them.
            self._flushSendBIO()
开发者ID:BillAndersan,项目名称:twisted,代码行数:36,代码来源:tls.py

示例2: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
 def makeConnection(self, transport):
     directlyProvides(self, providedBy(transport))
     Protocol.makeConnection(self, transport)
     self.transport.write("o")
     self.factory.registerProtocol(self)
     self.wrappedProtocol.makeConnection(self)
     self.heartbeat_timer = reactor.callLater(self.parent._options['heartbeat'], self.heartbeat)
开发者ID:INTERACT-IV,项目名称:sockjs-twisted,代码行数:9,代码来源:websocket.py

示例3: build_protocol

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
def build_protocol():
    """
    :return: ``Protocol`` hooked up to transport.
    """
    p = Protocol()
    p.makeConnection(StringTransport())
    return p
开发者ID:punalpatel,项目名称:flocker,代码行数:9,代码来源:test_loop.py

示例4: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
    def makeConnection(self, transport):
        """
        Connect this wrapper to the given transport and initialize the
        necessary L{OpenSSL.SSL.Connection} with a memory BIO.
        """
        self._tlsConnection = self.factory._createConnection(self)
        self._appSendBuffer = []

        # Add interfaces provided by the transport we are wrapping:
        for interface in providedBy(transport):
            directlyProvides(self, interface)

        # Intentionally skip ProtocolWrapper.makeConnection - it might call
        # wrappedProtocol.makeConnection, which we want to make conditional.
        Protocol.makeConnection(self, transport)
        self.factory.registerProtocol(self)
        if self._connectWrapped:
            # Now that the TLS layer is initialized, notify the application of
            # the connection.
            ProtocolWrapper.makeConnection(self, transport)

        # Now that we ourselves have a transport (initialized by the
        # ProtocolWrapper.makeConnection call above), kick off the TLS
        # handshake.
        self._checkHandshakeStatus()
开发者ID:esabelhaus,项目名称:secret-octo-dubstep,代码行数:27,代码来源:tls.py

示例5: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
 def makeConnection(self, transport):
     if isinstance(self.factory, OutgoingConnectionFactory):
         self.factory.rawserver._remove_pending_connection(self.factory.addr)
     self.can_timeout = 1
     self.setTimeout(self.factory.rawserver.config['socket_timeout'])
     self.attachTransport(transport, self.factory.connection, *self.factory.connection_args)
     Protocol.makeConnection(self, transport)
开发者ID:casibbald,项目名称:kamaelia,代码行数:9,代码来源:RawServer_twisted.py

示例6: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
 def makeConnection(self, transport):
     directlyProvides(self, providedBy(transport))
     Protocol.makeConnection(self, transport)
     
     if not self.method in self.allowedMethods:
         self.sendHeaders({'status': '405 Method Not Supported','allow': ', '.join(self.allowedMethods)})
         self.transport.write("\r\n")
         self.transport.loseConnection()
         return
     elif self.method == 'OPTIONS':
         self.sendHeaders()
         self.transport.write("")
         self.transport.loseConnection()
         return
     
     if not self.writeOnly:
         if self.session in self.factory.sessions:
             self.wrappedProtocol = self.factory.sessions[self.session]
         else:
             self.wrappedProtocol = RelayProtocol(self.factory, self.factory.wrappedFactory.buildProtocol(self.transport.addr), self.session, self)
         
         if self.wrappedProtocol.attached:
             self.wrappedProtocol = None
             self.failConnect()
         else:
             if not self.prepConnection():
                 self.disconnecting = False
                 self.wrappedProtocol.makeConnection(self)
     else:
         if self.session in self.factory.sessions:
             self.wrappedProtocol = self.factory.sessions[self.session]
         else:
             self.sendHeaders({'status': '404 Not Found'})
             self.transport.write("\r\n")
             self.transport.loseConnection()
开发者ID:ojii,项目名称:sockjs-twisted,代码行数:37,代码来源:base.py

示例7: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
 def makeConnection(self, transport):
     directlyProvides(self, providedBy(transport))
     Protocol.makeConnection(self, transport)
     if self.wrappedProtocol:
         self.prepConnection()
         self.wrappedProtocol.makeConnection(self)
     else:
         self.failConnect()
开发者ID:lvh,项目名称:sockjs-twisted,代码行数:10,代码来源:rawwebsocket.py

示例8: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
 def makeConnection(self, transport):
     """
     overload Protocol.makeConnection in order to get a reference to the
     transport
     """
     log.msg("ResponseProducerProtocol makeConnection", 
             logLevel=logging.DEBUG)
     Protocol.makeConnection(self, transport)
开发者ID:SpiderOak,项目名称:twisted_client_for_nimbusio,代码行数:10,代码来源:response_producer_protocol.py

示例9: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
 def makeConnection(self, transport):
     """
     When a connection is made, register this wrapper with its factory,
     save the real transport, and connect the wrapped protocol to this
     L{ProtocolWrapper} to intercept any transport calls it makes.
     """
     directlyProvides(self, providedBy(transport))
     Protocol.makeConnection(self, transport)
     self.factory.registerProtocol(self)
     self.wrappedProtocol.makeConnection(self)
开发者ID:Almad,项目名称:twisted,代码行数:12,代码来源:policies.py

示例10: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
    def makeConnection(self, transport):
        """
        Connects the factory to us and us to the underlying transport.

        L{CompressingProtocol.makeConnection}() can't be used because it calls
        makeConnection on the wrapped protocol, which causes a second full
        initialization, while the stream just needs a reset (done by
        L{CompressInitiatingInitializer}).
        """
        directlyProvides(self, providedBy(transport))
        Protocol.makeConnection(self, transport)
        self.factory.registerProtocol(self)
        self.wrappedProtocol.transport = self
        transport.protocol = self
开发者ID:BillTheBest,项目名称:xmppserver,代码行数:16,代码来源:compression.py

示例11: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
    def makeConnection(self, transport):
        self.attachTransport(transport, self.wrapper)

        self.can_timeout = True
        self.setTimeout(self.factory.rawserver.config.get('socket_timeout', 30))
        
        return Protocol.makeConnection(self, transport)
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:9,代码来源:RawServer_twisted.py

示例12: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
    def makeConnection(self, transport):
        directlyProvides(self, providedBy(transport))
        Protocol.makeConnection(self, transport)
        self.factory.registerProtocol(self)

        # We implement only Anonymous access
        self.transport.write(struct.pack("!BB", 5, len(b"\x00")) + b"\x00")

        self.transport.write(struct.pack("!BBBBB", 5, 1, 0, 3, len(self._host)) + self._host + struct.pack("!H", self._port))
        self.wrappedProtocol.makeConnection(self)

        try:
            self._connectedDeferred.callback(self.wrappedProtocol)
        except Exception:
            pass

        self.state = 1
开发者ID:chojar,项目名称:GlobaLeaks,代码行数:19,代码来源:socks.py

示例13: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
    def makeConnection(self, transport):
        """
        When a connection is made, register this wrapper with its factory,
        save the real transport, and connect the wrapped protocol to this
        L{ProtocolWrapper} to intercept any transport calls it makes.
        """
        directlyProvides(self, providedBy(transport))
        Protocol.makeConnection(self, transport)
        self.factory.registerProtocol(self)

        # We implement only Anonymous access
        self.transport.write(struct.pack("!BB", 5, len("\x00")) + "\x00")

        if self._optimistic:
            self.transport.write(struct.pack("!BBBBB", 5, 1, 0, 3, len(self._host)) + self._host + struct.pack("!H", self._port))
            self.wrappedProtocol.makeConnection(self)
            try:
                self._connectedDeferred.callback(self.wrappedProtocol)
            except Exception:
                pass

        self.state += 1
开发者ID:Acidburn0zzz,项目名称:Tor2web-3.0,代码行数:24,代码来源:socks.py

示例14: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
    def makeConnection(self, transport):
        """
        Connect this wrapper to the given transport and initialize the
        necessary L{OpenSSL.SSL.Connection} with a memory BIO.
        """
        self._tlsConnection = self.factory._createConnection(self)
        self._appSendBuffer = []

        # Add interfaces provided by the transport we are wrapping:
        for interface in providedBy(transport):
            directlyProvides(self, interface)

        # Intentionally skip ProtocolWrapper.makeConnection - it might call
        # wrappedProtocol.makeConnection, which we want to make conditional.
        Protocol.makeConnection(self, transport)
        self.factory.registerProtocol(self)
        if self._connectWrapped:
            # Now that the TLS layer is initialized, notify the application of
            # the connection.
            ProtocolWrapper.makeConnection(self, transport)

        # Now that we ourselves have a transport (initialized by the
        # ProtocolWrapper.makeConnection call above), kick off the TLS
        # handshake.

        # The connection might already be aborted (eg. by a callback during
        # connection setup), so don't even bother trying to handshake in that
        # case.
        if not self._aborted:
            try:
                self._tlsConnection.do_handshake()
            except WantReadError:
                # This is the expected case - there's no data in the
                # connection's input buffer yet, so it won't be able to
                # complete the whole handshake now. If this is the speak-first
                # side of the connection, then some bytes will be in the send
                # buffer now; flush them.
                self._flushSendBIO()
开发者ID:Architektor,项目名称:PySnip,代码行数:40,代码来源:tls.py

示例15: makeConnection

# 需要导入模块: from twisted.internet.protocol import Protocol [as 别名]
# 或者: from twisted.internet.protocol.Protocol import makeConnection [as 别名]
 def makeConnection(self, transport):
     self.can_timeout = 1
     self.setTimeout(self.factory.rawserver.config['socket_timeout'])
     self.attachTransport(transport, self.factory.connection, *self.factory.connection_args)
     Protocol.makeConnection(self, transport)
开发者ID:rays,项目名称:ipodderx-core,代码行数:7,代码来源:RawServer_twisted.py


注:本文中的twisted.internet.protocol.Protocol.makeConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。