本文整理汇总了Python中twisted.internet.protocol.ServerFactory.buildProtocol方法的典型用法代码示例。如果您正苦于以下问题:Python ServerFactory.buildProtocol方法的具体用法?Python ServerFactory.buildProtocol怎么用?Python ServerFactory.buildProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.protocol.ServerFactory
的用法示例。
在下文中一共展示了ServerFactory.buildProtocol方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unconnected_proxyserver
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def unconnected_proxyserver(mocker):
mocker.patch("twisted.test.iosim.FakeTransport.startTLS")
mocker.patch("pappyproxy.proxy.load_certs_from_dir", new=mock_generate_cert)
factory = ServerFactory()
factory.protocol = ProxyServer
protocol = factory.buildProtocol(('127.0.0.1', 0))
protocol.makeConnection(FakeTransport(protocol, True))
return protocol
示例2: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, address):
"""
Builds the protocol to a given address.
:rtype : Protocol
"""
p = ServerFactory.buildProtocol(self, address)
return p
示例3: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
from carbon.conf import settings
# Don't establish the connection if we have reached the limit.
if len(state.connectedMetricReceiverProtocols) < settings.MAX_RECEIVER_CONNECTIONS:
return ServerFactory.buildProtocol(self, addr)
else:
return None
示例4: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
clients = len(state.connectedMetricReceiverProtocols)
max_clients = settings.MAX_RECEIVER_CONNECTIONS
if clients < max_clients:
return ServerFactory.buildProtocol(self, addr)
else:
return None
示例5: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
p = ServerFactory.buildProtocol(self, addr)
p.service = self
self.clients[p] = {"from": addr,
"connected": time.time(),
"rx": 0,
"tx": 0,
"subscriptions": set()}
return p
示例6: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
"""
Build the L{NodeServerProtocol} instance and add a callback when the
connection has been successfully established to the other node.
"""
p = ServerFactory.buildProtocol(self, addr)
p._connectDeferred = Deferred()
p._connectDeferred.addCallback(self._putInCache)
return p
示例7: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, address):
"""
Builds the protocol to a given address.
:rtype : Protocol
"""
logger.debug("Building protocol to address %s", address)
p = ServerFactory.buildProtocol(self, address)
return p
示例8: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, address):
proto = ServerFactory.buildProtocol(self, address)
self.clients[self.next_id] = proto
if self.client_waiting is None:
self.client_waiting = self.next_id
else:
self.game(self.client_waiting, self.next_id)
self.client_waiting = None
self.next_id += 1
return proto
示例9: proxyserver
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def proxyserver(mocker):
mocker.patch("twisted.test.iosim.FakeTransport.startTLS")
mocker.patch("pappyproxy.proxy.load_certs_from_dir", new=mock_generate_cert)
factory = ServerFactory()
factory.protocol = ProxyServer
protocol = factory.buildProtocol(('127.0.0.1', 0))
protocol.makeConnection(FakeTransport(protocol, True))
protocol.lineReceived('CONNECT https://www.AAAA.BBBB:443 HTTP/1.1')
protocol.lineReceived('')
protocol.transport.getOutBuffer()
return protocol
示例10: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
password = self.settings.get('iphone', 'password')
if password:
protocol = ServerFactory.buildProtocol(self, addr)
protocol.window = self.window
protocol.settings = self.settings
protocol.iocontroller = self.iocontroller
return protocol
wx.MessageBox(_('''An iPhone or iPod Touch tried to connect to Task Coach,\n'''
'''but no password is set. Please set a password in the\n'''
'''iPhone section of the configuration and try again.'''),
_('Error'), wx.OK)
return None
示例11: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
p = ServerFactory.buildProtocol(self, addr)
p.context_manager = ContextManager(self.context_path)
return p
示例12: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
p = ServerFactory.buildProtocol(self, addr)
p.addr = addr
return p
示例13: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
protocol = ServerFactory.buildProtocol(self, addr)
self.reactor.callLater(0, self.result.callback, protocol)
return protocol
示例14: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
protocol = ServerFactory.buildProtocol(self, addr)
protocol.io = self.io
self.io.addClient(protocol)
return protocol
示例15: buildProtocol
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import buildProtocol [as 别名]
def buildProtocol(self, addr):
self.logger.info('Client connected: '+repr(addr))
return ServerFactory.buildProtocol(self, addr)