Support SRTools web
This commit is contained in:
@@ -5,6 +5,7 @@ from game_server.net.packet import NetOperation
|
||||
from game_server.net.session import PlayerSession
|
||||
from utils.logger import Info,Warn,Debug
|
||||
from database.mongodb import get_database
|
||||
from game_server.srtools.gateway import set_gateway_instance
|
||||
|
||||
|
||||
class KCPGateway(asyncio.DatagramProtocol):
|
||||
@@ -17,6 +18,12 @@ class KCPGateway(asyncio.DatagramProtocol):
|
||||
self.timeout_check_interval = 5
|
||||
self.save_duration = 60
|
||||
|
||||
def get_active_connection(self,uid) -> PlayerSession:
|
||||
for key, session in self.sessions.items():
|
||||
if session.player.data.uid == uid:
|
||||
return session
|
||||
return None
|
||||
|
||||
async def check_sessions_timeout(self):
|
||||
while self.running:
|
||||
for conv_id, session in list(self.sessions.items()):
|
||||
@@ -134,6 +141,8 @@ class KCPGateway(asyncio.DatagramProtocol):
|
||||
lambda: KCPGateway(db), local_addr=(host, port)
|
||||
)
|
||||
|
||||
set_gateway_instance(protocol)
|
||||
|
||||
try:
|
||||
await protocol.shutdown_event.wait()
|
||||
except asyncio.CancelledError:
|
||||
|
||||
Reference in New Issue
Block a user