friends: Handle coming online
This commit is contained in:
parent
120dbd684a
commit
20d58f41e5
|
|
@ -783,6 +783,9 @@ class LoadAvatarOperation(AvatarOperation):
|
|||
|
||||
self.loginManager.air.setOwner(self.avId, channel)
|
||||
|
||||
friendsList = [friendId for friendId, _ in self.avatar['setFriendsList'][0]]
|
||||
self.loginManager.air.toontownFriendsManager.comingOnline(self.avId, friendsList)
|
||||
|
||||
self._handleDone()
|
||||
|
||||
|
||||
|
|
@ -799,6 +802,8 @@ class UnloadAvatarOperation(GameOperation):
|
|||
def __handleUnloadAvatar(self):
|
||||
channel = self.loginManager.GetAccountConnectionChannel(self.sender)
|
||||
|
||||
self.loginManager.air.toontownFriendsManager.goingOffline(self.avId)
|
||||
|
||||
datagram = PyDatagram()
|
||||
datagram.addServerHeader(channel, self.loginManager.air.ourChannel, CLIENTAGENT_CLEAR_POST_REMOVES)
|
||||
self.loginManager.air.send(datagram)
|
||||
|
|
|
|||
|
|
@ -346,6 +346,35 @@ class RemoveFriendOperation(FriendsOperation):
|
|||
FriendsOperation._handleDone(self)
|
||||
|
||||
|
||||
class ComingOnlineOperation(FriendsOperation):
|
||||
|
||||
def __init__(self, friendsManager):
|
||||
FriendsOperation.__init__(self, friendsManager, None)
|
||||
self.avId = None
|
||||
self.friendsList = None
|
||||
self.currentFriendIdx = None
|
||||
|
||||
def start(self, avId, friendsList):
|
||||
self.avId = avId
|
||||
self.friendsList = friendsList
|
||||
self.__checkFriendsOnline()
|
||||
|
||||
def __checkFriendsOnline(self):
|
||||
self.currentFriendIdx = 0
|
||||
for friendId in self.friendsList:
|
||||
self.friendsManager.air.getActivated(friendId, self.__gotFriendActivated)
|
||||
|
||||
def __gotFriendActivated(self, avId, activated):
|
||||
self.currentFriendIdx += 1
|
||||
if activated:
|
||||
self.friendsManager.declareObject(avId, self.avId)
|
||||
self.friendsManager.declareObject(self.avId, avId)
|
||||
self.friendsManager.sendFriendOnline(avId, self.avId, 0, 1)
|
||||
|
||||
if self.currentFriendIdx >= len(self.friendsList):
|
||||
self._handleDone()
|
||||
|
||||
|
||||
class ToontownFriendsManagerUD(DistributedObjectGlobalUD):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('ToontownFriendsManagerUD')
|
||||
|
||||
|
|
@ -414,3 +443,6 @@ class ToontownFriendsManagerUD(DistributedObjectGlobalUD):
|
|||
|
||||
def removeFriend(self, friendId):
|
||||
self.runSenderOperation(RemoveFriendOperation, friendId)
|
||||
|
||||
def comingOnline(self, avId, friendsList):
|
||||
self.runServerOperation(ComingOnlineOperation, avId, friendsList)
|
||||
|
|
|
|||
Loading…
Reference in New Issue