2016-05-18 17:12:46 +00:00
|
|
|
from objects import glob
|
|
|
|
from constants import serverPackets
|
2016-04-19 17:40:59 +00:00
|
|
|
|
|
|
|
def handle(userToken, packetData):
|
|
|
|
# get token data
|
|
|
|
userID = userToken.userID
|
|
|
|
|
|
|
|
# Send spectator frames to every spectator
|
2016-10-04 20:10:07 +00:00
|
|
|
glob.streams.broadcast("spect/{}".format(userID), serverPackets.spectatorFrames(packetData[7:]))
|
|
|
|
'''for i in userToken.spectators:
|
2016-04-19 17:40:59 +00:00
|
|
|
# Send to every user but host
|
|
|
|
if i != userID:
|
|
|
|
try:
|
|
|
|
# Get spectator token object
|
|
|
|
spectatorToken = glob.tokens.getTokenFromUserID(i)
|
|
|
|
|
|
|
|
# Make sure the token exists
|
2016-09-02 15:45:10 +00:00
|
|
|
if spectatorToken is None:
|
2016-04-19 17:40:59 +00:00
|
|
|
raise exceptions.stopSpectating
|
|
|
|
|
|
|
|
# Make sure this user is spectating us
|
|
|
|
if spectatorToken.spectating != userID:
|
|
|
|
raise exceptions.stopSpectating
|
|
|
|
|
|
|
|
# Everything seems fine, send spectator frames to this spectator
|
|
|
|
spectatorToken.enqueue(serverPackets.spectatorFrames(packetData[7:]))
|
|
|
|
except exceptions.stopSpectating:
|
|
|
|
# Remove this user from spectators
|
|
|
|
userToken.removeSpectator(i)
|
2016-10-04 20:10:07 +00:00
|
|
|
userToken.enqueue(serverPackets.removeSpectator(i))'''
|