mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-08 08:47:32 +08:00
Fix a bug and add a new thing
- Add support for logging Arcaea's errors - Fix a bug when world maps' data don't have some unnecessary parts the client of iOS may break down
This commit is contained in:
@@ -7,7 +7,7 @@ from flask import Blueprint, request
|
||||
from setting import Config
|
||||
|
||||
from .auth import auth_required
|
||||
from .func import error_return, success_return
|
||||
from .func import arc_try, success_return
|
||||
|
||||
bp = Blueprint('multiplayer', __name__, url_prefix='/multiplayer')
|
||||
|
||||
@@ -16,66 +16,57 @@ conn1, conn2 = Pipe()
|
||||
|
||||
@bp.route('/me/room/create', methods=['POST']) # 创建房间
|
||||
@auth_required(request)
|
||||
@arc_try
|
||||
def room_create(user_id):
|
||||
if not Config.UDP_PORT or Config.UDP_PORT == '':
|
||||
return error_return(ArcError('The local udp server is down.', 151)), 404
|
||||
raise ArcError('The local udp server is down.', 151, status=404)
|
||||
with Connect() as c:
|
||||
try:
|
||||
x = LocalMultiPlayer(conn1)
|
||||
user = Player(c, user_id)
|
||||
user.get_song_unlock(request.json['clientSongMap'])
|
||||
x.create_room(user)
|
||||
r = x.to_dict()
|
||||
r['endPoint'] = request.host.split(
|
||||
':')[0] if Config.LINK_PLAY_HOST == '' else Config.LINK_PLAY_HOST
|
||||
r['port'] = int(Config.UDP_PORT)
|
||||
return success_return(r)
|
||||
except ArcError as e:
|
||||
return error_return(e), 400
|
||||
return error_return()
|
||||
x = LocalMultiPlayer(conn1)
|
||||
user = Player(c, user_id)
|
||||
user.get_song_unlock(request.json['clientSongMap'])
|
||||
x.create_room(user)
|
||||
r = x.to_dict()
|
||||
r['endPoint'] = request.host.split(
|
||||
':')[0] if Config.LINK_PLAY_HOST == '' else Config.LINK_PLAY_HOST
|
||||
r['port'] = int(Config.UDP_PORT)
|
||||
return success_return(r)
|
||||
|
||||
|
||||
@bp.route('/me/room/join/<room_code>', methods=['POST']) # 加入房间
|
||||
@auth_required(request)
|
||||
@arc_try
|
||||
def room_join(user_id, room_code):
|
||||
if not Config.UDP_PORT or Config.UDP_PORT == '':
|
||||
return error_return(ArcError('The local udp server is down.', 151)), 404
|
||||
raise ArcError('The local udp server is down.', 151, status=404)
|
||||
|
||||
with Connect() as c:
|
||||
try:
|
||||
x = LocalMultiPlayer(conn1)
|
||||
user = Player(c, user_id)
|
||||
user.get_song_unlock(request.json['clientSongMap'])
|
||||
room = Room()
|
||||
room.room_code = room_code
|
||||
x.join_room(room, user)
|
||||
r = x.to_dict()
|
||||
r['endPoint'] = request.host.split(
|
||||
':')[0] if Config.LINK_PLAY_HOST == '' else Config.LINK_PLAY_HOST
|
||||
r['port'] = int(Config.UDP_PORT)
|
||||
return success_return(r)
|
||||
except ArcError as e:
|
||||
return error_return(e), 400
|
||||
return error_return()
|
||||
x = LocalMultiPlayer(conn1)
|
||||
user = Player(c, user_id)
|
||||
user.get_song_unlock(request.json['clientSongMap'])
|
||||
room = Room()
|
||||
room.room_code = room_code
|
||||
x.join_room(room, user)
|
||||
r = x.to_dict()
|
||||
r['endPoint'] = request.host.split(
|
||||
':')[0] if Config.LINK_PLAY_HOST == '' else Config.LINK_PLAY_HOST
|
||||
r['port'] = int(Config.UDP_PORT)
|
||||
return success_return(r)
|
||||
|
||||
|
||||
@bp.route('/me/update', methods=['POST']) # 更新房间
|
||||
@auth_required(request)
|
||||
@arc_try
|
||||
def multiplayer_update(user_id):
|
||||
if not Config.UDP_PORT or Config.UDP_PORT == '':
|
||||
return error_return(ArcError('The local udp server is down.', 151)), 404
|
||||
raise ArcError('The local udp server is down.', 151, status=404)
|
||||
|
||||
with Connect() as c:
|
||||
try:
|
||||
x = LocalMultiPlayer(conn1)
|
||||
user = Player(c, user_id)
|
||||
user.token = int(request.json['token'])
|
||||
x.update_room(user)
|
||||
r = x.to_dict()
|
||||
r['endPoint'] = request.host.split(
|
||||
':')[0] if Config.LINK_PLAY_HOST == '' else Config.LINK_PLAY_HOST
|
||||
r['port'] = int(Config.UDP_PORT)
|
||||
return success_return(r)
|
||||
except ArcError as e:
|
||||
return error_return(e), 400
|
||||
return error_return()
|
||||
x = LocalMultiPlayer(conn1)
|
||||
user = Player(c, user_id)
|
||||
user.token = int(request.json['token'])
|
||||
x.update_room(user)
|
||||
r = x.to_dict()
|
||||
r['endPoint'] = request.host.split(
|
||||
':')[0] if Config.LINK_PLAY_HOST == '' else Config.LINK_PLAY_HOST
|
||||
r['port'] = int(Config.UDP_PORT)
|
||||
return success_return(r)
|
||||
|
||||
Reference in New Issue
Block a user