Casper 1 kuukausi sitten
vanhempi
commit
f9412b4275
3 muutettua tiedostoa jossa 13 lisäystä ja 21 poistoa
  1. 1 1
      sri-server-bg01/key/v1.py
  2. 8 1
      sri-server-bg03/hub.py
  3. 4 19
      sri-server-bg03/lib/Connection_e1.py

+ 1 - 1
sri-server-bg01/key/v1.py

@@ -71,7 +71,7 @@ async def get_token(request: Request, response: Response):
         }
         Global.mdb.add('UserLoginLog', data)
         code = 3
-    elif int(user.get('state')) == 1:
+    elif user.get('state') and int(user.get('state')) == 1:
         code = 4
     else:
         data = {

+ 8 - 1
sri-server-bg03/hub.py

@@ -4,11 +4,18 @@ import importlib
 sys.path.append('../sri-pysdk')
 
 methods = importlib.import_module(f"xlib")
+protobuf = importlib.import_module(f"xprotobuf.protocol_pb2")
 
 
 class Global(object):
+    """
+    """
+
+    # ---服务端口
+    egoserver_port = 20918
+
     pb = importlib.import_module(f"protobuf.protocol_pb2")
 
     # --- 业务数据数据库 ---
     mdb = importlib.import_module(f"xclient.xmongo").Client(host='127.0.0.1', port=47017, database='bg',
-                                                            username='admin', password='admin')
+                                                            username='admin', password='admin')

+ 4 - 19
sri-server-bg03/lib/Connection_e1.py

@@ -1,6 +1,6 @@
 """
 """
-# from hub import methods, Global
+from hub import methods, Global, protobuf
 
 from werkzeug.security import check_password_hash
 import struct
@@ -8,21 +8,6 @@ import asyncio
 import time
 import socket
 
-import sys
-import importlib
-
-# --- for linux
-# sys.path.append('/home/sri/repositories/repositories/SRI-DINO.Server-py/sri-server-bg03')
-# sys.path.append('/home/sri/repositories/repositories/SRI-DINO.Server-py/sri-pysdk')
-
-# --- for windows
-sys.path.append(r'C:\SRI-DINO.Server-py\sri-server-bg03')
-sys.path.append(r'C:\SRI-DINO.Server-py\sri-pysdk')
-
-protobuf = importlib.import_module(f"xprotobuf.protocol_pb2")
-methods = importlib.import_module(f"xlib")
-mdb = importlib.import_module(f"xclient.xmongo").Client(host='127.0.0.1', port=47017, database='bg',
-                                                        username='admin', password='admin')
 clients = {}  # {<ipv4>: (socket, update_at, type)} | {<连接id>: (socket对象, 最后一次请求时间, 客户端类型)}
 serial_rid_dict = {
     '65F7171A-5585-46C7-A9D6-967ABA9EB223': 1000000,
@@ -290,7 +275,7 @@ class SRIConnection(asyncio.Protocol):
             ret = False
 
         # --- check ---
-        user = mdb.get_one('UserInfo', {'username': object.account})
+        user = Global.mdb.get_one('UserInfo', {'username': object.account})
         name = ''
         uuid = ''
         if not user:
@@ -666,12 +651,12 @@ class SRIConnection(asyncio.Protocol):
         loop = asyncio.get_running_loop()
         server = await loop.create_server(
             lambda: SRIConnection(),
-            '0.0.0.0', 20917
+            '0.0.0.0', Global.egoserver_port
         )
 
         # --- start ---
         async with server:
-            print("Server listening on 0.0.0.0:20917", flush=True)
+            print(f"Server listening on 0.0.0.0:{Global.egoserver_port}", flush=True)
             # await loop.create_task(SRIConnection.check_clients())
             await server.serve_forever()