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


Python PyDatagram.addUint16方法代码示例

本文整理汇总了Python中direct.distributed.PyDatagram.addUint16方法的典型用法代码示例。如果您正苦于以下问题:Python PyDatagram.addUint16方法的具体用法?Python PyDatagram.addUint16怎么用?Python PyDatagram.addUint16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在direct.distributed.PyDatagram的用法示例。


在下文中一共展示了PyDatagram.addUint16方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: login

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
    def login(self, cookie, sig):
        self.notify.debug("Received login cookie %r from %d" % (cookie, self.air.getMsgSender()))

        sender = self.air.getMsgSender()

        if not self.loginsEnabled:
            # Logins are currently disabled... RIP!
            dg = PyDatagram()
            dg.addServerHeader(sender, self.air.ourChannel, CLIENTAGENT_EJECT)
            dg.addUint16(200)
            dg.addString("Logins are currently disabled. Please try again later.")
            self.air.send(dg)

        if sender >> 32:
            # Oops, they have an account ID on their connection already!
            self.killConnection(sender, "Client is already logged in.")
            return

        # Test the signature
        key = (
            config.GetString("csmud-secret", "streetlamps")
            + config.GetString("server-version", "no_version_set")
            + FIXED_KEY
        )
        computedSig = hmac.new(key, cookie, hashlib.sha256).digest()
        if sig != computedSig:
            self.killConnection(sender, "The accounts database rejected your cookie")
            return

        if sender in self.connection2fsm:
            self.killConnectionFSM(sender)
            return

        self.connection2fsm[sender] = LoginAccountFSM(self, sender)
        self.connection2fsm[sender].request("Start", cookie)
开发者ID:TLOTT-PS,项目名称:ttr-src,代码行数:37,代码来源:ClientServicesManagerUD.py

示例2: enterSetAccount

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [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')
开发者ID:Puggyblue999,项目名称:PiratesOfTheCarribeanOnline,代码行数:32,代码来源:ClientServicesManagerUD.py

示例3: killConnection

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
 def killConnection(self, connId, reason):
     datagram = PyDatagram()
     datagram.addServerHeader(
         connId,
         self.air.ourChannel,
         CLIENTAGENT_EJECT)
     datagram.addUint16(122)
     datagram.addString(reason)
     self.air.send(datagram)
开发者ID:Toonerz,项目名称:TTI-Leak--From-2015-,代码行数:11,代码来源:ClientServicesManagerUD.py

示例4: login

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
    def login(self, cookie):
        target = self.air.getMsgSender()

        datagram = PyDatagram()
        datagram.addServerHeader(
            target,
            self.air.ourChannel,
            CLIENTAGENT_SET_STATE)
        datagram.addUint16(2)
        self.air.send(datagram)

        self.sendUpdateToChannel(target, 'acceptLogin', [])
开发者ID:PiratesOnline,项目名称:PiratesOfTheCarribeanOnline,代码行数:14,代码来源:ClientServicesManagerUD.py

示例5: packGardenData

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
def packGardenData(plants, statuary, started = True):
    dg = PyDatagram()
    for plant in plants:
        a, b, c, d, e = plant
        dg.addUint32(a)
        dg.addInt8(b)
        dg.addUint32(c)
        dg.addInt8(d)
        dg.addUint16(e)

    dg.addUint8(statuary)
    dg.addBool(started)
    return dg.getMessage()
开发者ID:Teku16,项目名称:MikeyTheRepository,代码行数:15,代码来源:DistributedEstateAI.py

示例6: enterSetAccount

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [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')
开发者ID:Keithybub,项目名称:ToonTownReviveOld,代码行数:53,代码来源:ClientServicesManagerUD.py

示例7: enterSetAccount

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [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')
开发者ID:gamerdave54321,项目名称:Toontown-House-Code,代码行数:46,代码来源:ClientServicesManagerUD.py

示例8: __comingOnlineFriendOnline

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
    def __comingOnlineFriendOnline(self, avId, activated, otherId=None):
        if not (otherId and activated):
            #??!?!?
            return
        # Declare our avatar to their friend.
        dg = PyDatagram()
        dg.addServerHeader(self.GetPuppetConnectionChannel(avId), self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
        dg.addUint32(otherId)
        dg.addUint16(self.air.dclassesByName['DistributedToonUD'].getNumber())
        self.air.send(dg)

        # Declare the friend to the avatar.
        dg = PyDatagram()
        dg.addServerHeader(self.GetPuppetConnectionChannel(otherId), self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
        dg.addUint32(avId)
        dg.addUint16(self.air.dclassesByName['DistributedToonUD'].getNumber())
        self.air.send(dg)

        # Tell the client their friend is online.
        self.sendUpdateToAvatarId(avId, 'friendOnline', [otherId, 0, 0])
开发者ID:AdrianF98,项目名称:Toontown-Rewritten,代码行数:22,代码来源:TTRFriendsManagerUD.py

示例9: inviteeFriendResponse

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
    def inviteeFriendResponse(self, response, context):
        avId = self.air.getAvatarIdFromSender()
        if not context in self.requests:
            self.air.writeServerEvent('suspicious', avId=avId, issue='Player tried to respond to a friend request that doesn\'t exist!')
            return
        if avId != self.requests[context][0][1]:
            self.air.writeServerEvent('suspicious', avId=avId, issue='Player tried to respond to someone else\'s request!')
            return
        if self.requests[context][1] == 'cancelled':
            self.air.writeServerEvent('suspicious', avId=avId, issue='Player tried to respond to non-active friend request!')
            return
        self.sendUpdateToAvatarId(self.requests[context][0][0], 'friendResponse', [response, context])
        if response == 1:
            requested = self.air.doId2do.get(self.requests[context][0][1])
            requester = self.air.doId2do.get(self.requests[context][0][0])

            if not (requested and requester):
                # Likely they logged off just before a response was sent. RIP.
                return


            # Allow both toons to teleport to each other.
            dg = PyDatagram()
            dg.addServerHeader(self.GetPuppetConnectionChannel(requested.getDoId()), self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
            dg.addUint32(requester.getDoId())
            dg.addUint16(self.air.dclassesByName['DistributedToonAI'].getNumber())
            self.air.send(dg)

            dg = PyDatagram()
            dg.addServerHeader(self.GetPuppetConnectionChannel(requester.getDoId()), self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
            dg.addUint32(requested.getDoId())
            dg.addUint16(self.air.dclassesByName['DistributedToonAI'].getNumber())
            self.air.send(dg)

            requested.extendFriendsList(requester.getDoId(), 0)
            requester.extendFriendsList(requested.getDoId(), 0)

            requested.d_setFriendsList(requested.getFriendsList())
            requester.d_setFriendsList(requester.getFriendsList())
        del self.requests[context]
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leaked-Source,代码行数:42,代码来源:FriendManagerAI.py

示例10: d_updateBlock

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
 def d_updateBlock(self, bldg):
     if not bldg in self.bldgs:
         return
         
     data = bldg.getPickleData()
     
     dg = PyDatagram()
     dg.addUint16(bldg.zoneId - (bldg.zoneId % 1000))
     dg.addUint16(bldg.zoneId)
     dg.addUint8(int(data['block']))
     
     state = data['state'].lower()
     
     if state.startswith('clear'):
         state = 'cogdo' if state.endswith('cogdo') else 'suit'
         
     dg.addString(state)
     
     dg.addUint8(ord(data['track']))
     dg.addUint8(int(data['difficulty']))
     dg.addInt8(int(data['numFloors']))
     
     self.sendUpdate("doUpdate", ["block", dg.getMessage()])
开发者ID:ToontownModder101,项目名称:Toontown-Offline-Squirting-Flower-Modded-,代码行数:25,代码来源:ShardAPIManagerAI.py

示例11: d_setShardData

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
    def d_setShardData(self):
        dg = PyDatagram()
        
        self.context += 1
        self.context %= 200
        dg.addUint8(self.context)
        
        buildings = self.air.doFindAllInstances(DistributedBuildingAI.DistributedBuildingAI)
        for bldg in buildings:
            if bldg.__class__ in (DistributedBuildingAI.DistributedBuildingAI, DistributedAnimBuildingAI.DistributedAnimBuildingAI):
                if not bldg.zoneId % 1000:
                    # sz bldg, ignore
                    continue
                    
                if bldg.zoneId // 1000 == 7:
                    # ff bldg, ignore now
                    continue
                    
                data = bldg.getPickleData()

                dg.addString("block")
                dg.addUint16(bldg.zoneId - (bldg.zoneId % 1000))
                dg.addUint16(bldg.zoneId)
                dg.addUint8(int(data['block']))
                dg.addString(data['state'].lower())
                dg.addUint8(ord(data['track']))
                dg.addUint8(int(data['difficulty']))
                dg.addInt8(int(data['numFloors']))
                
                self.bldgs.add(bldg)
                    
        self.writeInvasion(dg)                    
        self.sendUpdate("setShardData", [dg.getMessage()])
                            
        self.air.notify.info("Sent shard data to UD")
        taskMgr.doMethodLater(60, self.__timeout, 'UD-sync-timeout')
开发者ID:ToontownModder101,项目名称:Toontown-Offline-Squirting-Flower-Modded-,代码行数:38,代码来源:ShardAPIManagerAI.py

示例12: enterSetAccount

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [as 别名]
    def enterSetAccount(self):
        # If necessary, update their account information:
        if self.accessLevel:
            self.csm.air.dbInterface.updateObject(
                self.csm.air.dbId,
                self.accountId,
                self.csm.air.dclassesByName['AccountUD'],
                {'ACCESS_LEVEL': self.accessLevel})

        # 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)

        # Subscribe to any "staff" channels that the account has access to.
        access = self.account.get('ADMIN_ACCESS', 0)
        if access >= 200:
            # Subscribe to the moderator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_MOD_CHANNEL)
            self.csm.air.send(dg)
        if access >= 400:
            # Subscribe to the administrator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_ADMIN_CHANNEL)
            self.csm.air.send(dg)
        if access >= 500:
            # Subscribe to the system administrator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_SYSADMIN_CHANNEL)
            self.csm.air.send(dg)

        # 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(),
             'LAST_LOGIN_TS': time.time(),
             '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.time())])
        self.demand('Off')
开发者ID:ToontownBattlefront,项目名称:Toontown-Battlefront,代码行数:83,代码来源:ClientServicesManagerUD.py

示例13: enterSetAccount

# 需要导入模块: from direct.distributed import PyDatagram [as 别名]
# 或者: from direct.distributed.PyDatagram import addUint16 [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)

        # Subscribe to any "staff" channels that the account has access to.
        access = self.account.get("ADMIN_ACCESS", 0)
        if access >= 200:
            # Subscribe to the moderator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_MOD_CHANNEL)
            self.csm.air.send(dg)
        if access >= 400:
            # Subscribe to the administrator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_ADMIN_CHANNEL)
            self.csm.air.send(dg)
        if access >= 500:
            # Subscribe to the system administrator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_SYSADMIN_CHANNEL)
            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. BIG FAT SECURITY RISK!!!
        self.csm.air.send(dg)

        # 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(),
                "ACCOUNT_ID": self.databaseId,
                "ADMIN_ACCESS": self.adminAccess,
                "BETA_KEY_QUEST": self.betaKeyQuest,
            },
        )

        # Add a POST_REMOVE to the connection channel to execute the NetMessenger
        # message when the account connection goes RIP on the Client Agent.
        dgcleanup = self.csm.air.netMessenger.prepare("accountDisconnected", [self.accountId])
        dg = PyDatagram()
        dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
        dg.addString(dgcleanup.getMessage())
        self.csm.air.send(dg)

        # We're done.
        self.csm.air.writeServerEvent(
            "account-login", clientId=self.target, accId=self.accountId, webAccId=self.databaseId, cookie=self.cookie
        )
        self.csm.sendUpdateToChannel(self.target, "acceptLogin", [])
        self.demand("Off")
开发者ID:TLOTT-PS,项目名称:ttr-src,代码行数:78,代码来源:ClientServicesManagerUD.py


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