2016-10-02 22:48:14 +02:00
|
|
|
from common.log import logUtils as log
|
2016-05-18 19:12:46 +02:00
|
|
|
from constants import exceptions
|
2016-10-02 22:48:14 +02:00
|
|
|
from constants import serverPackets
|
|
|
|
from objects import glob
|
|
|
|
|
2016-04-19 19:40:59 +02:00
|
|
|
|
2016-09-02 17:45:10 +02:00
|
|
|
def handle(userToken, _):
|
2016-04-19 19:40:59 +02:00
|
|
|
try:
|
|
|
|
# We don't have the beatmap, we can't spectate
|
2016-10-07 13:43:47 +02:00
|
|
|
if userToken.spectating not in glob.tokens.tokens:
|
2016-10-07 13:44:00 +02:00
|
|
|
raise exceptions.tokenNotFoundException()
|
2016-04-19 19:40:59 +02:00
|
|
|
|
|
|
|
# Send the packet to host
|
2016-10-07 13:43:47 +02:00
|
|
|
glob.tokens.tokens[userToken.spectating].enqueue(serverPackets.noSongSpectator(userToken.userID))
|
2016-04-19 19:40:59 +02:00
|
|
|
except exceptions.tokenNotFoundException:
|
|
|
|
# Stop spectating if token not found
|
2016-06-04 12:44:54 +02:00
|
|
|
log.warning("Spectator can't spectate: token not found")
|
2016-04-19 19:40:59 +02:00
|
|
|
userToken.stopSpectating()
|