2016-05-18 17:12:46 +00:00
|
|
|
from objects import glob
|
|
|
|
from constants import serverPackets
|
|
|
|
from constants import exceptions
|
2016-06-04 10:44:54 +00:00
|
|
|
from helpers import logHelper as log
|
2016-04-19 17:40:59 +00:00
|
|
|
|
|
|
|
def handle(userToken, packetData):
|
|
|
|
# get usertoken data
|
|
|
|
userID = userToken.userID
|
|
|
|
|
|
|
|
try:
|
|
|
|
# We don't have the beatmap, we can't spectate
|
|
|
|
target = userToken.spectating
|
|
|
|
targetToken = glob.tokens.getTokenFromUserID(target)
|
|
|
|
|
|
|
|
# Send the packet to host
|
|
|
|
targetToken.enqueue(serverPackets.noSongSpectator(userID))
|
|
|
|
except exceptions.tokenNotFoundException:
|
|
|
|
# Stop spectating if token not found
|
2016-06-04 10:44:54 +00:00
|
|
|
log.warning("Spectator can't spectate: token not found")
|
2016-04-19 17:40:59 +00:00
|
|
|
userToken.stopSpectating()
|