.BANCHO. Add support for tournament client

This commit is contained in:
Nyo
2016-10-05 23:28:26 +02:00
parent 795b6f09be
commit 996287f871
13 changed files with 91 additions and 25 deletions

View File

@@ -104,8 +104,10 @@ def handle(tornadoRequest):
userUtils.logIP(userID, requestIP)
# Delete old tokens for that user and generate a new one
glob.tokens.deleteOldTokens(userID)
responseToken = glob.tokens.addToken(userID, requestIP, timeOffset=timeOffset)
isTournament = "tourney" in osuVersion
if not isTournament:
glob.tokens.deleteOldTokens(userID)
responseToken = glob.tokens.addToken(userID, requestIP, timeOffset=timeOffset, tournament=isTournament)
responseTokenString = responseToken.token
# Check restricted mode (and eventually send message)
@@ -205,7 +207,7 @@ def handle(tornadoRequest):
if userUtils.getCountry(userID) == "XX":
userUtils.setCountry(userID, countryLetters)
# Send to everyone our userpanel if we are not restricted
# Send to everyone our userpanel if we are not restricted or tournament
if not responseToken.restricted:
glob.streams.broadcast("main", serverPackets.userPanel(userID))

View File

@@ -0,0 +1,11 @@
from constants import clientPackets
from objects import glob
from helpers import chatHelper as chat
def handle(userToken, packetData):
packetData = clientPackets.tournamentJoinMatchChannel(packetData)
matchID = packetData["matchID"]
if matchID not in glob.matches.matches:
return
userToken.matchID = matchID
chat.joinChannel(token=userToken, channel="#multi_{}".format(matchID))

View File

@@ -0,0 +1,11 @@
from constants import clientPackets
from objects import glob
from helpers import chatHelper as chat
def handle(userToken, packetData):
packetData = clientPackets.tournamentLeaveMatchChannel(packetData)
matchID = packetData["matchID"]
if matchID not in glob.matches.matches:
return
chat.partChannel(token=userToken, channel="#multi_{}".format(matchID))
userToken.matchID = 0

View File

@@ -0,0 +1,10 @@
from constants import clientPackets
from constants import serverPackets
from objects import glob
def handle(userToken, packetData):
packetData = clientPackets.tournamentMatchInfoRequest(packetData)
matchID = packetData["matchID"]
if matchID not in glob.matches.matches:
return
userToken.enqueue(serverPackets.updateMatch(matchID))