本文整理汇总了Python中panda3d.core.QueuedConnectionReader.setTcpHeaderSize方法的典型用法代码示例。如果您正苦于以下问题:Python QueuedConnectionReader.setTcpHeaderSize方法的具体用法?Python QueuedConnectionReader.setTcpHeaderSize怎么用?Python QueuedConnectionReader.setTcpHeaderSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.QueuedConnectionReader
的用法示例。
在下文中一共展示了QueuedConnectionReader.setTcpHeaderSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from panda3d.core import QueuedConnectionReader [as 别名]
# 或者: from panda3d.core.QueuedConnectionReader import setTcpHeaderSize [as 别名]
class Server:
def __init__(self):
self.activeConnections = [] # lists all connections
self.players = {} # keys are the players logins, values are the players datagram connections
self.parties = {} # keys are the parties names, values are dicts representing parties data
self.sessions = {} # keys are the datagram connections, values are dicts storing the characters of the player and its party
self.playersinlobby = [] # lists players in the party screen
self.charid = 0 # used for random team generation
self.chars = [] # lists of dicts representing characters data
self.cManager = QueuedConnectionManager()
self.cListener = QueuedConnectionListener(self.cManager, 0)
self.cReader = QueuedConnectionReader(self.cManager, 0)
self.cReader.setTcpHeaderSize(4)
self.send = Send(self.cManager)
port = 3001
if len(sys.argv) > 1:
port = sys.argv[1]
self.tcpSocket = self.cManager.openTCPServerRendezvous(port, 10)
self.cListener.addConnection(self.tcpSocket)
print("Server listening on port", port)
taskMgr.add(self.tskListenerPolling, "Poll the connection listener", -39)
taskMgr.add(self.tskReaderPolling, "Poll the connection reader", -40)
def processData(self, datagram):
iterator = PyDatagramIterator(datagram)
source = datagram.getConnection()
callback = iterator.getString()
getattr(globals()[callback], 'execute')(self, iterator, source)
def updateAllPartyLists(self):
parties = deepcopy(self.parties)
for party in list(parties.values()):
del party['map']['tiles']
for player in self.playersinlobby:
self.send.UPDATE_PARTY_LIST(parties, player)
def tskListenerPolling(self, taskdata):
if self.cListener.newConnectionAvailable():
rendezvous = PointerToConnection()
netAddress = NetAddress()
newConnection = PointerToConnection()
if self.cListener.getNewConnection(rendezvous, netAddress, newConnection):
newConnection = newConnection.p()
self.activeConnections.append(newConnection)
self.cReader.addConnection(newConnection)
print('A new client is connected', newConnection)
return Task.cont
def tskReaderPolling(self, taskdata):
if self.cReader.dataAvailable():
datagram=NetDatagram()
if self.cReader.getData(datagram):
self.processData(datagram)
return Task.cont