mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-11 10:27:27 +08:00
[Bug Fix][Enhance] About Link Play
- Fix a bug that the room host will be changed late when finishing a song - Add logging module for linkplay server
This commit is contained in:
@@ -37,13 +37,13 @@ class Constant:
|
||||
DOWNLOAD_TIME_GAP_LIMIT = Config.DOWNLOAD_TIME_GAP_LIMIT
|
||||
DOWNLOAD_LINK_PREFIX = Config.DOWNLOAD_LINK_PREFIX
|
||||
|
||||
LINK_PLAY_UNLOCK_LENGTH = 512 # Units: bytes
|
||||
LINK_PLAY_TIMEOUT = 5 # Units: seconds
|
||||
LINKPLAY_UNLOCK_LENGTH = 512 # Units: bytes
|
||||
LINKPLAY_TIMEOUT = 5 # Units: seconds
|
||||
|
||||
LINK_PLAY_HOST = '127.0.0.1' if Config.SET_LINK_PLAY_SERVER_AS_SUB_PROCESS else Config.LINK_PLAY_HOST
|
||||
LINK_PLAY_TCP_PORT = Config.LINK_PLAY_TCP_PORT
|
||||
LINK_PLAY_UDP_PORT = Config.LINK_PLAY_UDP_PORT
|
||||
LINK_PLAY_AUTHENTICATION = Config.LINK_PLAY_AUTHENTICATION
|
||||
LINKPLAY_HOST = '127.0.0.1' if Config.SET_LINKPLAY_SERVER_AS_SUB_PROCESS else Config.LINKPLAY_HOST
|
||||
LINKPLAY_TCP_PORT = Config.LINKPLAY_TCP_PORT
|
||||
LINKPLAY_UDP_PORT = Config.LINKPLAY_UDP_PORT
|
||||
LINKPLAY_AUTHENTICATION = Config.LINKPLAY_AUTHENTICATION
|
||||
|
||||
COURSE_STAMINA_COST = 4
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ from core.error import ArcError, Timeout
|
||||
from .constant import Constant
|
||||
from .user import UserInfo
|
||||
|
||||
socket.setdefaulttimeout(Constant.LINK_PLAY_TIMEOUT)
|
||||
socket.setdefaulttimeout(Constant.LINKPLAY_TIMEOUT)
|
||||
|
||||
|
||||
def get_song_unlock(client_song_map: dict) -> bytes:
|
||||
'''处理可用歌曲bit,返回bytes'''
|
||||
|
||||
user_song_unlock = [0] * Constant.LINK_PLAY_UNLOCK_LENGTH
|
||||
for i in range(0, Constant.LINK_PLAY_UNLOCK_LENGTH*2, 2):
|
||||
user_song_unlock = [0] * Constant.LINKPLAY_UNLOCK_LENGTH
|
||||
for i in range(0, Constant.LINKPLAY_UNLOCK_LENGTH*2, 2):
|
||||
x = 0
|
||||
y = 0
|
||||
if str(i) in client_song_map:
|
||||
@@ -98,8 +98,8 @@ class RemoteMultiPlayer:
|
||||
@staticmethod
|
||||
def tcp(data: str) -> str:
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||
sock.connect((Constant.LINK_PLAY_HOST,
|
||||
Constant.LINK_PLAY_TCP_PORT))
|
||||
sock.connect((Constant.LINKPLAY_HOST,
|
||||
Constant.LINKPLAY_TCP_PORT))
|
||||
sock.sendall(bytes(data + "\n", "utf-8"))
|
||||
try:
|
||||
received = str(sock.recv(1024), "utf-8").strip()
|
||||
@@ -111,7 +111,7 @@ class RemoteMultiPlayer:
|
||||
|
||||
def data_swap(self, data: tuple) -> tuple:
|
||||
|
||||
received = self.tcp(Constant.LINK_PLAY_AUTHENTICATION +
|
||||
received = self.tcp(Constant.LINKPLAY_AUTHENTICATION +
|
||||
'|' + '|'.join([str(x) for x in data]))
|
||||
|
||||
self.data_recv = received.split('|')
|
||||
|
||||
Reference in New Issue
Block a user