本文整理汇总了Python中pandac.PandaModules.NetDatagram.getConnection方法的典型用法代码示例。如果您正苦于以下问题:Python NetDatagram.getConnection方法的具体用法?Python NetDatagram.getConnection怎么用?Python NetDatagram.getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.NetDatagram
的用法示例。
在下文中一共展示了NetDatagram.getConnection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getData
# 需要导入模块: from pandac.PandaModules import NetDatagram [as 别名]
# 或者: from pandac.PandaModules.NetDatagram import getConnection [as 别名]
def getData(self):
data = []
while self.cReader.dataAvailable():
datagram = NetDatagram()
if self.cReader.getData(datagram):
if datagram.getConnection() in self.tempConnections:
if self.auth(datagram):
self.tempConnections.remove(datagram.getConnection())
continue
# Check if the data recieved is from a valid client.
for client in self.activeClients:
if datagram.getConnection() == client.connection:
data.append(('client', self.processData(datagram), client))
break
# Check if the data recieved is from a valid server.
for server in self.activeServers:
if datagram.getConnection() == server.connection:
data.append(('server', self.processData(datagram), server))
break
# Check if the data recieved is from a valid chat.
for chat in self.activeChats:
if datagram.getConnection() == chat.connection:
data.append(('chat', self.processData(datagram), chat))
break
return data
示例2: getData
# 需要导入模块: from pandac.PandaModules import NetDatagram [as 别名]
# 或者: from pandac.PandaModules.NetDatagram import getConnection [as 别名]
def getData(self):
data = []
for passed in self.passedData:
data.append(passed)
self.passedData.remove(passed)
while self.cReader.dataAvailable():
datagram = NetDatagram()
if self.cReader.getData(datagram):
if datagram.getConnection() in self.tempConnections:
self.processTempConnection(datagram)
continue
for authed in self.users:
if datagram.getConnection() == authed.connection:
data.append((self.processData(datagram), datagram.getConnection()))
return data
示例3: getData
# 需要导入模块: from pandac.PandaModules import NetDatagram [as 别名]
# 或者: from pandac.PandaModules.NetDatagram import getConnection [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):
appendage={}
appendage[0]=self.processData(datagram)
appendage[1]=datagram.getConnection()
data.append(appendage)
return data
示例4: getData
# 需要导入模块: from pandac.PandaModules import NetDatagram [as 别名]
# 或者: from pandac.PandaModules.NetDatagram import getConnection [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):
if datagram.getConnection() in self.tempConnections:
print "Check Auth!"
self.auth(datagram)
print "Auth Done!"
# in auth def or after the connection will be moved to self.activeConnections
# and then removed from the temp list
break
# Check if the data rechieved is from a valid client.
elif datagram.getConnection() in self.activeConnections:
appendage = {}
appendage[0] = self.processData(datagram)
appendage[1] = datagram.getConnection()
data.append(appendage)
return data
示例5: __readTask
# 需要导入模块: from pandac.PandaModules import NetDatagram [as 别名]
# 或者: from pandac.PandaModules.NetDatagram import getConnection [as 别名]
def __readTask(self, Task):
''' This task listens for any messages coming in over any connections.
If we get a connection passes it to the datagram handler.'''
if self._cReader.dataAvailable():
datagram=NetDatagram()
if self._cReader.getData(datagram):
data = PyDatagramIterator(datagram)
msgID = data.getUint16()
else:
data = None
msgID = MSG_NONE
else:
datagram = None
data = None
msgID = MSG_NONE
if msgID is not MSG_NONE:
self.__handleDatagram(data, msgID, datagram.getConnection())
return Task.cont
示例6: __readTask
# 需要导入模块: from pandac.PandaModules import NetDatagram [as 别名]
# 或者: from pandac.PandaModules.NetDatagram import getConnection [as 别名]
def __readTask(self, taskdata):
''' This task listens for any messages coming in over any connections.
If we get a connection passes it to the datagram handler.'''
if 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):
data = PyDatagramIterator(datagram)
msgID = data.getUint16()
else:
data = None
msgID = MSG_NONE
else:
datagram = None
data = None
msgID = MSG_NONE
if msgID is not MSG_NONE:
self.__handleDatagram(data, msgID, datagram.getConnection())
return Task.cont