本文整理汇总了Python中twisted.internet.protocol.Protocol类的典型用法代码示例。如果您正苦于以下问题:Python Protocol类的具体用法?Python Protocol怎么用?Python Protocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Protocol类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: makeConnection
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,代码行数:7,代码来源:RawServer_twisted.py
示例2: makeConnection
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,代码行数:7,代码来源:websocket.py
示例3: __init__
def __init__(self):
try:
Protocol.__init__(self)
except AttributeError:
pass
self.buffer = ""
self.drd = Deferred()
开发者ID:mgax,项目名称:monocle,代码行数:7,代码来源:__init__.py
示例4: makeConnection
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,代码行数:34,代码来源:tls.py
示例5: __init__
def __init__(self):
Protocol.__init__(self)
self.packetBuffer = ''
self.packetSize = 0
self.errorMsg = ''
self.errorId = 0
self.msgMap = {}
开发者ID:Oralordos,项目名称:Multiplayer-Survive,代码行数:7,代码来源:gprotocol.py
示例6: connectionMade
def connectionMade(self):
"""
overload Protocol.connectionMade to verify that we have a connection
"""
log.msg("ResponseProducerProtocol connectionMade",
logLevel=logging.DEBUG)
Protocol.connectionMade(self)
开发者ID:SpiderOak,项目名称:twisted_client_for_nimbusio,代码行数:7,代码来源:response_producer_protocol.py
示例7: connectionLost
def connectionLost(self, reason):
Protocol.connectionLost(self, reason)
self.started = False
self.factory.number_of_connections -= 1
self.player = None
print "lost"
print "Current number of connections:", self.factory.number_of_connections
开发者ID:asafebgi,项目名称:adilate-flash-gui,代码行数:7,代码来源:player_protocol.py
示例8: makeConnection
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,代码行数:25,代码来源:tls.py
示例9: build_protocol
def build_protocol():
"""
:return: ``Protocol`` hooked up to transport.
"""
p = Protocol()
p.makeConnection(StringTransport())
return p
开发者ID:punalpatel,项目名称:flocker,代码行数:7,代码来源:test_loop.py
示例10: makeConnection
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,代码行数:35,代码来源:base.py
示例11: connectionMade
def connectionMade(self):
Protocol.connectionMade(self)
self.transport.setTcpNoDelay(True)
self.buffer = ''
self.nbytes = 0
# XXX send version message
self._handler = self._handle_version, 12
开发者ID:askervin,项目名称:vncdotool,代码行数:8,代码来源:loggingproxy.py
示例12: makeConnection
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,代码行数:8,代码来源:rawwebsocket.py
示例13: makeConnection
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,代码行数:8,代码来源:response_producer_protocol.py
示例14: connectionMade
def connectionMade(self):
AbstractWind.connectionMade(self)
Protocol.connectionMade(self)
_ = self.transport.getPeer()
_ = (_.host, _.port)
self.peer, self.port = _
开发者ID:ComputerNetworks-UFRGS,项目名称:ManP2P-ng,代码行数:8,代码来源:wind.py
示例15: reconnector
def reconnector(self, onion):
protocol = Protocol()
protocol.onion = onion
protocol.connectionLost = lambda failure: self.handleLostConnection(failure, onion)
tor_endpoint = clientFromString(self.reactor, "tor:%s.onion:8060" % onion)
self.onion_pending_map[onion] = connectProtocol(tor_endpoint, protocol)
self.onion_pending_map[onion].addCallback(lambda protocol: self.connection_ready(onion, protocol))
self.onion_pending_map[onion].addErrback(lambda failure: self.connectFail(failure, onion))
开发者ID:hotelzululima,项目名称:onionvpn,代码行数:8,代码来源:ipv6_onion_consumer.py
示例16: connectionMade
def connectionMade(self):
self.factory.num_connections += 1
Protocol.connectionMade(self)
self._input = ''
proto_version = ProtocolVersion().serialize()
server_state = ServerState().serialize()
#
self.send(proto_version)
开发者ID:serpent-project,项目名称:serpent,代码行数:8,代码来源:protocol.py
示例17: connectionLost
def connectionLost(self, reason):
# remove from channel and disconnect, reset state machine
if self in self.factory.channels[self.channel]:
self.factory.channels[self.channel].remove(self)
if self.factory.channels[self.channel].count <= 0:
del self.factory.channels[self.channel]
self.curState=ProtocolState.CO_NO
self.factory.notifyObservers("A dude left the channel", self.channel)
Protocol.connectionLost(self, reason=reason)
开发者ID:nihathrael,项目名称:rateit,代码行数:9,代码来源:twistedserver.py
示例18: connectionMade
def connectionMade(self):
Protocol.connectionMade(self)
self.transport.write(struct.pack('>I', self.__seed))
self._input = ''
self._decompress = None
if self.__decompress:
self._decompress = Decompress()
开发者ID:cculianu,项目名称:gemuo,代码行数:9,代码来源:client.py
示例19: connectionLost
def connectionLost(self, reason = connectionDone):
log.info('SyncAnyProtocol::connectionLost')
self.started = False
Protocol.connectionLost(self, reason)
#self.factory.clients.remove(self)
if not self.user is None:
self.factory.clients.removeClient(self)
开发者ID:edceza,项目名称:syncanything,代码行数:9,代码来源:sync_any_server.py
示例20: connectionMade
def connectionMade(self):
self.log = util.getLogger("gamespy.login", self)
self.loggedIn = False
def sendKa():
self.sendMsg(MessageFactory.getMessage([("ka", "")]))
self.kaService.alive() ## expects no reply
self.kaService = KeepaliveService(sendKa, 90, self.transport.loseConnection)
Protocol.connectionMade(self)
开发者ID:istobran,项目名称:eaEmu,代码行数:10,代码来源:login.py
注:本文中的twisted.internet.protocol.Protocol类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论