.BANCHO. Add spectator list

This commit is contained in:
russelg 2016-06-08 23:26:31 +08:00 committed by Nyo
parent f9d6e79447
commit 3f9bad3d21
3 changed files with 18 additions and 0 deletions

View File

@ -188,6 +188,12 @@ def spectatorFrames(data):
def noSongSpectator(userID):
return packetHelper.buildPacket(packetIDs.server_spectatorCantSpectate, [[userID, dataTypes.sInt32]])
def fellowSpectatorJoined(userID):
return packetHelper.buildPacket(packetIDs.server_fellowSpectatorJoined, [[userID, dataTypes.sInt32]])
def fellowSpectatorLeft(userID):
return packetHelper.buildPacket(packetIDs.server_fellowSpectatorLeft, [[userID, dataTypes.sInt32]])
""" Multiplayer Packets """
def createMatch(matchID):

View File

@ -41,6 +41,13 @@ def handle(userToken, packetData):
# First spectator, send #spectator join to host too
targetToken.enqueue(serverPackets.channelJoinSuccess(userID, "#spectator"))
# send fellowSpectatorJoined to all spectators
for c in targetToken.spectators:
if c is not userID:
targetToken.enqueue(serverPackets.fellowSpectatorJoined(c))
specToken = glob.tokens.getTokenFromUserID(c)
specToken.enqueue(serverPackets.fellowSpectatorJoined(userID))
# Console output
log.info("{} are spectating {}".format(username, userHelper.getUsername(packetData["userID"])))
except exceptions.tokenNotFoundException:

View File

@ -18,6 +18,11 @@ def handle(userToken, _):
# Send the spectator left packet to host
targetToken.enqueue(serverPackets.removeSpectator(userID))
for c in targetToken.spectators:
spec = glob.tokens.getTokenFromUserID(c)
spec.enqueue(serverPackets.fellowSpectatorLeft(userID))
targetToken.enqueue(serverPackets.fellowSpectatorLeft(userID))
# Console output
# TODO: Move messages in stop spectating