本文整理汇总了Python中direct.distributed.PyDatagram.addChannel方法的典型用法代码示例。如果您正苦于以下问题:Python PyDatagram.addChannel方法的具体用法?Python PyDatagram.addChannel怎么用?Python PyDatagram.addChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.distributed.PyDatagram
的用法示例。
在下文中一共展示了PyDatagram.addChannel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enterUnloadAvatar
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterUnloadAvatar(self):
channel = self.csm.GetAccountConnectionChannel(self.target)
# Tell FriendsManager somebody is logging off:
self.csm.air.friendsManager.toonOffline(self.avId)
# Clear off POSTREMOVE:
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_CLEAR_POST_REMOVES)
self.csm.air.send(dg)
# Remove avatar channel:
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_CLOSE_CHANNEL)
dg.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
self.csm.air.send(dg)
# Reset sender channel:
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
dg.addChannel(self.target<<32) # accountId in high 32 bits, no avatar in low
self.csm.air.send(dg)
# Unload avatar object:
dg = PyDatagram()
dg.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
dg.addUint32(self.avId)
self.csm.air.send(dg)
# Done!
self.csm.air.writeServerEvent('avatarUnload', self.avId)
self.demand('Off')
示例2: enterUnloadAvatar
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterUnloadAvatar(self):
channel = self.csm.GetAccountConnectionChannel(self.target)
# Fire off the avatarOffline message.
self.csm.air.netMessenger.send("avatarOffline", [self.avId])
# Get lost, POST_REMOVES!:
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_CLEAR_POST_REMOVES)
self.csm.air.send(dg)
# Remove avatar channel:
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_CLOSE_CHANNEL)
dg.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
self.csm.air.send(dg)
# Reset sender channel:
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
dg.addChannel(self.target << 32) # accountId in high 32 bits, no avatar in low
self.csm.air.send(dg)
# Unload avatar object:
dg = PyDatagram()
dg.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
dg.addUint32(self.avId)
self.csm.air.send(dg)
# Done!
self.csm.air.writeServerEvent("avatar-unload", avId=self.avId)
self.demand("Off")
示例3: handleConnected
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def handleConnected(self):
self.notify.info('Yarn. Waking up (This may take a while!).')
ToontownInternalRepository.handleConnected(self)
self.districtId = self.allocateChannel()
self.distributedDistrict = ToontownDistrictAI(self)
self.distributedDistrict.setName(self.districtName)
self.distributedDistrict.generateWithRequiredAndId(
self.districtId, self.getGameDoId(), 2)
# Claim ownership of that district...
dg = PyDatagram()
dg.addServerHeader(
self.districtId,
self.ourChannel,
STATESERVER_OBJECT_SET_AI)
dg.addChannel(self.ourChannel)
self.send(dg)
self.notify.info('Creating Global Managers')
self.createGlobals()
self.notify.info('Creating Toontown')
self.createZones()
self.statusSender.start()
self.distributedDistrict.b_setAvailable(1)
self.notify.info('District is now ready.')
示例4: enterSetAccount
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAccount(self):
# First, if there's anybody on the account, kill 'em for redundant login:
dg = PyDatagram()
dg.addServerHeader(self.csm.GetAccountConnectionChannel(int(self.databaseId)),
self.csm.air.ourChannel, CLIENTAGENT_EJECT)
dg.addUint16(100)
dg.addString('This account has been logged in elsewhere.')
self.csm.air.send(dg)
# Next, add this connection to the account channel.
dg = PyDatagram()
dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
dg.addChannel(self.csm.GetAccountConnectionChannel(self.databaseId))
self.csm.air.send(dg)
# Now set their sender channel to represent their account affiliation:
dg = PyDatagram()
dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
dg.addChannel(self.databaseId << 32) # accountId in high 32 bits, 0 in low (no avatar)
self.csm.air.send(dg)
# Un-sandbox them!
dg = PyDatagram()
dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_SET_STATE)
dg.addUint16(2) # ESTABLISHED state. BIG FAT SECURITY RISK!!!
self.csm.air.send(dg)
# We're done.
self.csm.sendUpdateToChannel(self.target, 'acceptLogin', [])
self.demand('Off')
示例5: handleConnected
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def handleConnected(self):
self.districtId = self.allocateChannel()
self.distributedDistrict = ToontownDistrictAI(self)
self.distributedDistrict.setName(self.districtName)
self.distributedDistrict.generateWithRequiredAndId(simbase.air.districtId, self.getGameDoId(), 2)
dg = PyDatagram()
dg.addServerHeader(simbase.air.districtId, simbase.air.ourChannel, STATESERVER_OBJECT_SET_AI)
dg.addChannel(simbase.air.ourChannel)
simbase.air.send(dg)
self.createGlobals()
self.createZones()
示例6: enterSetAvatarTask
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAvatarTask(self, channel, task):
# Finally, grant ownership and shut down.
datagram = PyDatagram()
datagram.addServerHeader(
self.avId,
self.csm.air.ourChannel,
STATESERVER_OBJECT_SET_OWNER)
datagram.addChannel(self.target<<32 | self.avId)
self.csm.air.send(datagram)
self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
self.demand('Off')
return task.done
示例7: enterSetAccount
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAccount(self):
# First, if there's anybody on the account, kill them for redundant login:
datagram = PyDatagram()
datagram.addServerHeader(
self.csm.GetAccountConnectionChannel(self.accountId),
self.csm.air.ourChannel,
CLIENTAGENT_EJECT)
datagram.addUint16(100)
datagram.addString('This account has been logged in from elsewhere.')
self.csm.air.send(datagram)
# Next, add this connection to the account channel.
datagram = PyDatagram()
datagram.addServerHeader(
self.target,
self.csm.air.ourChannel,
CLIENTAGENT_OPEN_CHANNEL)
datagram.addChannel(self.csm.GetAccountConnectionChannel(self.accountId))
self.csm.air.send(datagram)
# Now set their sender channel to represent their account affiliation:
datagram = PyDatagram()
datagram.addServerHeader(
self.target,
self.csm.air.ourChannel,
CLIENTAGENT_SET_CLIENT_ID)
# Account ID in high 32 bits, 0 in low (no avatar):
datagram.addChannel(self.accountId << 32)
self.csm.air.send(datagram)
# Un-sandbox them!
datagram = PyDatagram()
datagram.addServerHeader(
self.target,
self.csm.air.ourChannel,
CLIENTAGENT_SET_STATE)
datagram.addUint16(2) # ESTABLISHED
self.csm.air.send(datagram)
# Update the last login timestamp:
self.csm.air.dbInterface.updateObject(
self.csm.air.dbId,
self.accountId,
self.csm.air.dclassesByName['AccountUD'],
{'LAST_LOGIN': time.ctime(time.mktime(time.gmtime())),
'ACCOUNT_ID': str(self.userId)})
# We're done.
self.csm.air.writeServerEvent('accountLogin', self.target, self.accountId, self.userId)
self.csm.sendUpdateToChannel(self.target, 'acceptLogin', [int(time.mktime(time.gmtime()))])
self.demand('Off')
示例8: enterSetAvatarTask
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAvatarTask(self, channel, task):
# Finally, grant ownership and shut down.
datagram = PyDatagram()
datagram.addServerHeader(
self.avId,
self.csm.air.ourChannel,
STATESERVER_OBJECT_SET_OWNER)
datagram.addChannel(self.target<<32 | self.avId)
self.csm.air.send(datagram)
# Tell the GlobalPartyManager as well:
self.csm.air.globalPartyMgr.avatarJoined(self.avId)
self.csm.air.writeServerEventMessage('avatarChosen', self.avId, self.target)
self.demand('Off')
return task.done
示例9: enterSetAvatar
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAvatar(self):
channel = self.csm.GetAccountConnectionChannel(self.target)
# First, give them a POSTREMOVE to unload the avatar, just in case they
# disconnect while we're working.
datagramCleanup = PyDatagram()
datagramCleanup.addServerHeader(
self.avId,
channel,
STATESERVER_OBJECT_DELETE_RAM)
datagramCleanup.addUint32(self.avId)
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_ADD_POST_REMOVE)
datagram.addString(datagramCleanup.getMessage())
self.csm.air.send(datagram)
# Activate the avatar on the DBSS:
self.csm.air.sendActivate(
self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'],
{'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)],
'setBankMoney': [self.account.get('MONEY', 0)]})
# Next, add them to the avatar channel:
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_OPEN_CHANNEL)
datagram.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
self.csm.air.send(datagram)
# Now set their sender channel to represent their account affiliation:
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_SET_CLIENT_ID)
datagram.addChannel(self.target<<32 | self.avId)
self.csm.air.send(datagram)
# Eliminate race conditions.
taskMgr.doMethodLater(0.2, self.enterSetAvatarTask,
'avatarTask-%s' % self.avId, extraArgs=[channel],
appendTask=True)
示例10: enterSetAccount
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAccount(self):
# First, if there's anybody on the account, kill 'em for redundant login:
dg = PyDatagram()
dg.addServerHeader(self.csm.GetAccountConnectionChannel(self.accountId),
self.csm.air.ourChannel, CLIENTAGENT_EJECT)
dg.addUint16(100)
dg.addString('This account has been logged in elsewhere.')
self.csm.air.send(dg)
# Next, add this connection to the account channel.
dg = PyDatagram()
dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
dg.addChannel(self.csm.GetAccountConnectionChannel(self.accountId))
self.csm.air.send(dg)
# Now set their sender channel to represent their account affiliation:
dg = PyDatagram()
dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
dg.addChannel(self.accountId << 32) # accountId in high 32 bits, 0 in low (no avatar)
self.csm.air.send(dg)
# Un-sandbox them!
dg = PyDatagram()
dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_SET_STATE)
dg.addUint16(2) # ESTABLISHED state.
self.csm.air.send(dg)
fields = {'LAST_LOGIN': time.ctime(), 'ACCOUNT_ID': str(self.databaseId)}
if self.adminAccess != -1:
fields.update({'ADMIN_ACCESS': self.adminAccess})
# Update the last login timestamp:
self.csm.air.dbInterface.updateObject(
self.csm.air.dbId,
self.accountId,
self.csm.air.dclassesByName['AccountUD'],
fields)
# We're done.
self.csm.air.writeServerEvent('accountLogin', self.target, self.accountId, self.databaseId)
self.csm.sendUpdateToChannel(self.target, 'acceptLogin', [])
self.csm.account2username[self.target] = self.username
self.demand('Off')
示例11: enterSetAvatarTask
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAvatarTask(self, channel, task):
# Finally, grant ownership and shut down.
datagram = PyDatagram()
datagram.addServerHeader(
self.avId,
self.csm.air.ourChannel,
STATESERVER_OBJECT_SET_OWNER)
datagram.addChannel(self.target<<32 | self.avId)
self.csm.air.send(datagram)
# Tell the GlobalPartyManager as well:
self.csm.air.globalPartyMgr.avatarJoined(self.avId)
fields = self.avatar
fields.update({'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)]})
self.csm.air.friendsManager.addToonData(self.avId, fields)
self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
self.demand('Off')
return task.done
示例12: enterUnloadAvatar
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterUnloadAvatar(self):
channel = self.csm.GetAccountConnectionChannel(self.target)
# Clear off POSTREMOVE:
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_CLEAR_POST_REMOVES)
self.csm.air.send(datagram)
# Remove avatar channel:
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_CLOSE_CHANNEL)
datagram.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
self.csm.air.send(datagram)
# Reset sender channel:
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_SET_CLIENT_ID)
datagram.addChannel(self.target<<32)
self.csm.air.send(datagram)
# Unload avatar object:
datagram = PyDatagram()
datagram.addServerHeader(
self.avId,
channel,
STATESERVER_OBJECT_DELETE_RAM)
datagram.addUint32(self.avId)
self.csm.air.send(datagram)
# Done!
self.csm.air.writeServerEvent('avatarUnload', self.avId)
self.demand('Off')
示例13: enterSetAvatar
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAvatar(self):
channel = self.csm.GetAccountConnectionChannel(self.target)
# First, give them a POSTREMOVE to unload the avatar, just in case they
# disconnect while we're working.
datagramCleanup = PyDatagram()
datagramCleanup.addServerHeader(
self.avId,
channel,
STATESERVER_OBJECT_DELETE_RAM)
datagramCleanup.addUint32(self.avId)
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_ADD_POST_REMOVE)
datagram.addString(datagramCleanup.getMessage())
self.csm.air.send(datagram)
# Activate the avatar on the DBSS:
self.csm.air.sendActivate(
self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'],
{'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)]})
# Next, add them to the avatar channel:
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_OPEN_CHANNEL)
datagram.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
self.csm.air.send(datagram)
# Now set their sender channel to represent their account affiliation:
datagram = PyDatagram()
datagram.addServerHeader(
channel,
self.csm.air.ourChannel,
CLIENTAGENT_SET_CLIENT_ID)
datagram.addChannel(self.target<<32 | self.avId)
self.csm.air.send(datagram)
# Finally, grant ownership and shut down.
datagram = PyDatagram()
datagram.addServerHeader(
self.avId,
self.csm.air.ourChannel,
STATESERVER_OBJECT_SET_OWNER)
datagram.addChannel(self.target<<32 | self.avId)
self.csm.air.send(datagram)
# Tell TTRFriendsManager somebody is logging in:
self.csm.air.friendsManager.toonOnline(self.avId, self.avatar)
# Tell the GlobalPartyManager as well:
self.csm.air.globalPartyMgr.avatarJoined(self.avId)
self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
self.demand('Off')
示例14: enterSetAvatar
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def enterSetAvatar(self):
channel = self.csm.GetAccountConnectionChannel(self.target)
# First, give them a POSTREMOVE to unload the avatar, just in case they
# disconnect while we're working.
dgcleanup = PyDatagram()
dgcleanup.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
dgcleanup.addUint32(self.avId)
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
dg.addString(dgcleanup.getMessage())
self.csm.air.send(dg)
# Get the avatar's "true" access. (without "server" bit)
adminAccess = self.account.get('ADMIN_ACCESS', 0)
adminAccess = adminAccess - adminAccess % 100
# Activate the avatar on the DBSS:
self.csm.air.sendActivate(self.avId, 0, 0,
self.csm.air.dclassesByName['DistributedToonUD'],
{'setAdminAccess': [self.account.get('ADMIN_ACCESS', 0)]})
# Next, add them to the avatar channel:
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
dg.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
self.csm.air.send(dg)
# Now set their sender channel to represent their account affiliation:
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
dg.addChannel(self.target<<32 | self.avId) # accountId in high 32 bits, avatar in low
self.csm.air.send(dg)
# Finally, grant ownership and shut down.
dg = PyDatagram()
dg.addServerHeader(self.avId, self.csm.air.ourChannel, STATESERVER_OBJECT_SET_OWNER)
dg.addChannel(self.csm.GetAccountConnectionChannel(self.target)) # Set ownership channel to the connection's account channel.
self.csm.air.send(dg)
# Tell the GlobalPartyManager as well:
self.csm.air.globalPartyMgr.avatarJoined(self.avId)
# Tell everything that an avatar is coming online!
friendsList = [x for x, y in self.avatar['setFriendsList'][0]]
self.csm.air.netMessenger.send('avatarOnline', [self.avId, friendsList])
# Post-remove for an avatar that disconnects unexpectedly.
dgcleanup = self.csm.air.netMessenger.prepare('avatarOffline', [self.avId])
dg = PyDatagram()
dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
dg.addString(dgcleanup.getMessage())
self.csm.air.send(dg)
self.csm.air.writeServerEvent('avatar-chosen', avId=self.avId, accId=self.target)
self.demand('Off')
示例15: createGlobals
# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addChannel [as 别名]
def createGlobals(self):
self.csm = simbase.air.generateGlobalObject(OTP_DO_ID_CLIENT_SERVICES_MANAGER,
'ClientServicesManager')
self.chatAgent = simbase.air.generateGlobalObject(OTP_DO_ID_CHAT_MANAGER,
'ChatAgent')
self.friendsManager = simbase.air.generateGlobalObject(OTP_DO_ID_TT_FRIENDS_MANAGER,
'TTFriendsManager')
self.globalPartyMgr = simbase.air.generateGlobalObject(OTP_DO_ID_GLOBAL_PARTY_MANAGER, 'GlobalPartyManager')
if config.GetBool('want-top-toons', True):
if OTP_DO_ID_TOONTOWN_TOP_TOONS_MGR == 100003:
self.topToonsMgr = DistributedTopToonsManagerUD(self)
self.topToonsMgr.generateWithRequiredAndId(100003, self.getGameDoId(), 2)
dg = PyDatagram()
dg.addServerHeader(100003, self.ourChannel, STATESERVER_OBJECT_SET_AI)
dg.addChannel(self.ourChannel)
self.send(dg)
else:
self.topToonsMgr = self.generateGlobalObject(OTP_DO_ID_TOONTOWN_TOP_TOONS_MGR, 'DistributedTopToonsManager')