def identifyFriend(self, doId, source = None): if doId in self.friendsMap: teleportNotify.debug('friend %s in friendsMap' % doId) return self.friendsMap[doId] avatar = None if doId in self.doId2do: teleportNotify.debug('found friend %s in doId2do' % doId) avatar = self.doId2do[doId] elif self.cache.contains(doId): teleportNotify.debug('found friend %s in cache' % doId) avatar = self.cache.dict[doId] elif self.playerFriendsManager.getAvHandleFromId(doId): teleportNotify.debug('found friend %s in playerFriendsManager' % doId) avatar = base.cr.playerFriendsManager.getAvHandleFromId(doId) else: self.notify.warning("Don't know who friend %s is." % doId) return if not ((isinstance(avatar, DistributedToon.DistributedToon) and avatar.__class__ is DistributedToon.DistributedToon) or isinstance(avatar, DistributedPet.DistributedPet)): self.notify.warning('friendsNotify%s: invalid friend object %s' % ((source, '(%s)' % source, ''), doId)) return if base.wantPets: if avatar.isPet(): if avatar.bFake: handle = PetHandle.PetHandle(avatar) else: handle = avatar else: handle = FriendHandle.FriendHandle(doId, avatar.getName(), avatar.style, avatar.getPetId()) else: handle = FriendHandle.FriendHandle(doId, avatar.getName(), avatar.style, '') teleportNotify.debug('adding %s to friendsMap' % doId) self.friendsMap[doId] = handle return handle
def handleGetFriendsList(self, resp): print(len(resp)) for toon in resp: doId = toon[0] name = toon[1] dnaString = toon[2] dna = ToonDNA.ToonDNA() dna.makeFromNetString(dnaString) petId = toon[3] handle = FriendHandle.FriendHandle(doId, name, dna, petId) self.friendsMap[doId] = handle if doId in self.friendsOnline: self.friendsOnline[doId] = handle if doId in self.friendPendingChatSettings: self.notify.debug('calling setCommonAndWL %s' % str(self.friendPendingChatSettings[doId])) handle.setCommonAndWhitelistChatFlags(*self.friendPendingChatSettings[doId]) if base.wantPets and base.localAvatar.hasPet(): def handleAddedPet(): self.friendsMapPending = 0 messenger.send('friendsMapComplete') self.addPetToFriendsMap(handleAddedPet) return self.friendsMapPending = 0 messenger.send('friendsMapComplete')
def handleGetFriendsListExtended(self, di): avatarHandleList = [] error = di.getUint8() if error: self.notify.warning('Got error return from friends list extended.') else: count = di.getUint16() for i in xrange(0, count): abort = 0 doId = di.getUint32() name = di.getString() if name == '': abort = 1 dnaString = di.getString() if dnaString == '': abort = 1 else: dna = ToonDNA.ToonDNA() dna.makeFromNetString(dnaString) petId = di.getUint32() if not abort: handle = FriendHandle.FriendHandle(doId, name, dna, petId) avatarHandleList.append(handle) if avatarHandleList: messenger.send('gotExtraFriendHandles', [avatarHandleList])
def handleGetFriendsListExtended(self, resp): for toon in resp: abort = 0 doId = toon[0] name = toon[1] if name == '': abort = 1 dnaString = toon[2] if dnaString == '': abort = 1 else: dna = ToonDNA.ToonDNA() dna.makeFromNetString(dnaString) petId = toon[3] if not abort: handle = FriendHandle.FriendHandle(doId, name, dna, petId) avatarHandleList.append(handle) if avatarHandleList: messenger.send('gotExtraFriendHandles', [avatarHandleList])