本文整理匯總了Python中pandac.PandaModules.NetDatagram.getAddress方法的典型用法代碼示例。如果您正苦於以下問題:Python NetDatagram.getAddress方法的具體用法?Python NetDatagram.getAddress怎麽用?Python NetDatagram.getAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandac.PandaModules.NetDatagram
的用法示例。
在下文中一共展示了NetDatagram.getAddress方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TCPPacketListenTask
# 需要導入模塊: from pandac.PandaModules import NetDatagram [as 別名]
# 或者: from pandac.PandaModules.NetDatagram import getAddress [as 別名]
def TCPPacketListenTask(self, task):
if self.tcpReader.dataAvailable():
datagram = NetDatagram()
if self.tcpReader.getData(datagram):
data = PyDatagramIterator(datagram)
ip = datagram.getAddress().getIpString()
port = datagram.getAddress().getPort()
peerAddr = NetAddress()
peerAddr.setHost(ip, port)
packetType = data.getUint8()
if(packetType == Packet.PC_TCP_PACKET):
self.tcpPacketController.OnPacketReceived(data, peerAddr)
return task.cont
示例2: UDPPacketListenTask
# 需要導入模塊: from pandac.PandaModules import NetDatagram [as 別名]
# 或者: from pandac.PandaModules.NetDatagram import getAddress [as 別名]
def UDPPacketListenTask(self, task):
while self.cReader.dataAvailable():
datagram = NetDatagram()
if self.cReader.getData(datagram):
#print 'PACKET', datagram
data = PyDatagramIterator(datagram)
ip = datagram.getAddress().getIpString()
port = datagram.getAddress().getPort()
peerAddr = NetAddress()
peerAddr.setHost(ip, port)
packetType = data.getUint8()
if(packetType == Packet.PC_RELIABLE_PACKET):
self.reliablePacketController.OnPacketReceived(data, peerAddr)
elif(packetType == Packet.PC_UNRELIABLE_PACKET):
self.unreliablePacketController.OnPacketReceived(data, peerAddr)
elif(packetType == Packet.PC_ENVIRONMENT_PACKET):
self.dataHandler.OnDataReceived(data, peerAddr, Packet.PC_ENVIRONMENT_PACKET)
return Task.cont
示例3: UDPPacketListenTask
# 需要導入模塊: from pandac.PandaModules import NetDatagram [as 別名]
# 或者: from pandac.PandaModules.NetDatagram import getAddress [as 別名]
def UDPPacketListenTask(self, task = None):
while self.cReader.dataAvailable():
datagram = NetDatagram()
if self.cReader.getData(datagram):
data = PyDatagramIterator(datagram)
ip = datagram.getAddress().getIpString()
port = datagram.getAddress().getPort()
peerAddr = NetAddress()
peerAddr.setHost(ip, port)
#print 'GOT UDP PACKET FROM', peerAddr.getIpString(), peerAddr.getPort()
isReliable = data.getUint8()
if(isReliable == Packet.PC_RELIABLE_PACKET):
self.reliablePacketController.OnPacketReceived(data, peerAddr)
elif(isReliable == Packet.PC_UNRELIABLE_PACKET):
self.unreliablePacketController.OnPacketReceived(data, peerAddr)
if(self.ClientIsConnected(peerAddr)):
self.GetActiveClient(peerAddr).timestamp = GameTime.time
return task.cont
示例4: getData
# 需要導入模塊: from pandac.PandaModules import NetDatagram [as 別名]
# 或者: from pandac.PandaModules.NetDatagram import getAddress [as 別名]
def getData(self):
data = []
while self.cReader.dataAvailable():
datagram = NetDatagram() # catch the incoming data in this instance
# Check the return value; if we were threaded, someone else could have
# snagged this data before we did
if self.cReader.getData(datagram):
# pkg = []
pkg = self._processData(datagram)
tmpaddr = datagram.getAddress()
addr = NetAddress()
addr.setHost(tmpaddr.getIpString(), tmpaddr.getPort())
pkg[ADDR] = addr
data.append(pkg)
return data