.BANCHO. Add spectator list
This commit is contained in:
parent
f9d6e79447
commit
3f9bad3d21
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user