.BANCHO. Add spectator list
This commit is contained in:
parent
f9d6e79447
commit
3f9bad3d21
|
@ -188,6 +188,12 @@ def spectatorFrames(data):
|
||||||
def noSongSpectator(userID):
|
def noSongSpectator(userID):
|
||||||
return packetHelper.buildPacket(packetIDs.server_spectatorCantSpectate, [[userID, dataTypes.sInt32]])
|
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 """
|
""" Multiplayer Packets """
|
||||||
def createMatch(matchID):
|
def createMatch(matchID):
|
||||||
|
|
|
@ -41,6 +41,13 @@ def handle(userToken, packetData):
|
||||||
# First spectator, send #spectator join to host too
|
# First spectator, send #spectator join to host too
|
||||||
targetToken.enqueue(serverPackets.channelJoinSuccess(userID, "#spectator"))
|
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
|
# Console output
|
||||||
log.info("{} are spectating {}".format(username, userHelper.getUsername(packetData["userID"])))
|
log.info("{} are spectating {}".format(username, userHelper.getUsername(packetData["userID"])))
|
||||||
except exceptions.tokenNotFoundException:
|
except exceptions.tokenNotFoundException:
|
||||||
|
|
|
@ -18,6 +18,11 @@ def handle(userToken, _):
|
||||||
|
|
||||||
# Send the spectator left packet to host
|
# Send the spectator left packet to host
|
||||||
targetToken.enqueue(serverPackets.removeSpectator(userID))
|
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
|
# Console output
|
||||||
# TODO: Move messages in stop spectating
|
# TODO: Move messages in stop spectating
|
||||||
|
|
Loading…
Reference in New Issue
Block a user