2016-10-02 20:48:14 +00:00
|
|
|
from common.log import logUtils as log
|
2016-05-18 17:12:46 +00:00
|
|
|
from constants import clientPackets
|
|
|
|
from constants import exceptions
|
2016-10-02 20:48:14 +00:00
|
|
|
from objects import glob
|
|
|
|
|
2016-04-19 17:40:59 +00:00
|
|
|
def handle(userToken, packetData):
|
|
|
|
try:
|
|
|
|
# Start spectating packet
|
|
|
|
packetData = clientPackets.startSpectating(packetData)
|
|
|
|
|
|
|
|
# Get host token
|
|
|
|
targetToken = glob.tokens.getTokenFromUserID(packetData["userID"])
|
2016-09-02 15:45:10 +00:00
|
|
|
if targetToken is None:
|
2016-04-19 17:40:59 +00:00
|
|
|
raise exceptions.tokenNotFoundException
|
|
|
|
|
2016-10-04 20:10:07 +00:00
|
|
|
# Start spectating new user
|
|
|
|
userToken.startSpectating(targetToken)
|
2016-04-19 17:40:59 +00:00
|
|
|
except exceptions.tokenNotFoundException:
|
|
|
|
# Stop spectating if token not found
|
2016-06-04 10:44:54 +00:00
|
|
|
log.warning("Spectator start: token not found")
|
2016-04-19 17:40:59 +00:00
|
|
|
userToken.stopSpectating()
|