Config packetlog
This commit is contained in:
@@ -10,6 +10,7 @@ from game_server.game.player.player_manager import PlayerManager
|
|||||||
from game_server.dummy import dummyprotolist
|
from game_server.dummy import dummyprotolist
|
||||||
import traceback
|
import traceback
|
||||||
from utils.time import cur_timestamp_ms
|
from utils.time import cur_timestamp_ms
|
||||||
|
from utils.config import Config
|
||||||
|
|
||||||
class PlayerSession:
|
class PlayerSession:
|
||||||
def __init__(self, transport, session_id, client_addr, db):
|
def __init__(self, transport, session_id, client_addr, db):
|
||||||
@@ -94,14 +95,16 @@ class PlayerSession:
|
|||||||
if not handle_result:
|
if not handle_result:
|
||||||
return
|
return
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
Error(f"Unhandled request {request_name}")
|
if Config.PacketLog:
|
||||||
|
Error(f"Unhandled request {request_name}")
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
Error(f"Handler {request_name} returns error.")
|
Error(f"Handler {request_name} returns error.")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return
|
return
|
||||||
|
|
||||||
Info(f"Received cmd: {request_name}({cmd_id})")
|
if Config.PacketLog:
|
||||||
|
Info(f"Received cmd: {request_name}({cmd_id})")
|
||||||
|
|
||||||
response_name = handle_result.__class__.__name__
|
response_name = handle_result.__class__.__name__
|
||||||
cmd_type = getattr(cmd.CmdID, response_name, None)
|
cmd_type = getattr(cmd.CmdID, response_name, None)
|
||||||
@@ -136,7 +139,8 @@ class PlayerSession:
|
|||||||
self.kcp.flush()
|
self.kcp.flush()
|
||||||
cmd_id = packet.cmd_type
|
cmd_id = packet.cmd_type
|
||||||
request_name = cmd.get_key_by_value(cmd_id)
|
request_name = cmd.get_key_by_value(cmd_id)
|
||||||
Info(f"Sent cmd: {request_name}({cmd_id})")
|
if Config.PacketLog:
|
||||||
|
Info(f"Sent cmd: {request_name}({cmd_id})")
|
||||||
|
|
||||||
def time(self):
|
def time(self):
|
||||||
return (cur_timestamp_ms()) - self.connect_time_ms
|
return (cur_timestamp_ms()) - self.connect_time_ms
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class ConfigData:
|
|||||||
SDKServer: ServerConfig
|
SDKServer: ServerConfig
|
||||||
SRToolsServer: ServerConfig
|
SRToolsServer: ServerConfig
|
||||||
RegionName: str
|
RegionName: str
|
||||||
|
PacketLog: bool
|
||||||
def write_default_config():
|
def write_default_config():
|
||||||
config = ConfigData(
|
config = ConfigData(
|
||||||
LogLevel="INFO",
|
LogLevel="INFO",
|
||||||
@@ -24,6 +25,7 @@ class ConfigData:
|
|||||||
SDKServer=ServerConfig(IP="127.0.0.1", Port=21000),
|
SDKServer=ServerConfig(IP="127.0.0.1", Port=21000),
|
||||||
SRToolsServer=ServerConfig(IP="127.0.0.1", Port=25000),
|
SRToolsServer=ServerConfig(IP="127.0.0.1", Port=25000),
|
||||||
RegionName="NeonSR",
|
RegionName="NeonSR",
|
||||||
|
PacketLog=True,
|
||||||
)
|
)
|
||||||
with open("Config.json", "w") as f:
|
with open("Config.json", "w") as f:
|
||||||
f.write(json.dumps(asdict(config), indent=2))
|
f.write(json.dumps(asdict(config), indent=2))
|
||||||
|
|||||||
Reference in New Issue
Block a user