當前位置: 首頁>>代碼示例>>Python>>正文


Python NetDatagram.getAddress方法代碼示例

本文整理匯總了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
開發者ID:czorn,項目名稱:Modifire,代碼行數:17,代碼來源:Client.py

示例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
開發者ID:czorn,項目名稱:Modifire,代碼行數:22,代碼來源:Client.py

示例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
開發者ID:czorn,項目名稱:Modifire,代碼行數:23,代碼來源:Server.py

示例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
開發者ID:lgo33,項目名稱:NetPanda,代碼行數:17,代碼來源:UDPconnection_thread.py


注:本文中的pandac.PandaModules.NetDatagram.getAddress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。