当前位置: 首页>>代码示例>>Python>>正文


Python NetDatagram.getConnection方法代码示例

本文整理汇总了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
开发者ID:H3LLB0Y,项目名称:Centipede,代码行数:27,代码来源:loginserver.py

示例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
开发者ID:H3LLB0Y,项目名称:Centipede,代码行数:17,代码来源:server.py

示例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
开发者ID:H3LLB0Y,项目名称:Warlocks,代码行数:14,代码来源:server.py

示例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
开发者ID:H3LLB0Y,项目名称:Warlocks,代码行数:25,代码来源:login_server_core.py

示例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
开发者ID:crempp,项目名称:psg,代码行数:20,代码来源:GameServer.py

示例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
开发者ID:crempp,项目名称:psg,代码行数:22,代码来源:ClientConnection.py


注:本文中的pandac.PandaModules.NetDatagram.getConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。