Ejemplo n.º 1
0
 def run(self):
     while self.m_bConnected:
         try:
             sData = self.m_oSocket.recv(1024 * 1024)
             if sData:
                 print(sData)
                 if sData == "CloseConnect":
                     self.Disconnected("Client Close Connect")
                     return
                 dData = json.loads(sData)
                 account = dData['account']
                 password = dData['password']
                 #print(account),password
                 if "score" in dData:
                     print("sava score")
                     score = dData['score']
                     time = dData['time']
                     pubglobalmanager.CallManagerFunc(
                         defines.DEMO, "SaveScore", self.m_ID, account,
                         score, time)
                 else:
                     print("login")
                     pubglobalmanager.CallManagerFunc(
                         defines.DEMO, "Login", self.m_ID, account,
                         password)
         except:
             self.Disconnected("recvfail")
             return
         try:
             self.Recv(sData)
         except:
             pubdefines.PythonError("recvfail2")
Ejemplo n.º 2
0
 def InitManger(self):
     try:
         pubdefines.FormatPrint("服务器监听开始")
         self.m_oSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         self.m_oSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
         self.m_oSocket.bind(("127.0.0.1", 12080))
         self.m_oSocket.listen(5)
     except:
         self.m_oSocket = None
         pubdefines.PythonError()
 def run(self):
     while self.m_bConnected:
         try:
             sData = self.m_oSocket.recv(1024 * 1024)
         except:
             self.Disconnected("recvfail")
             return
         try:
             self.Recv(sData)
         except:
             pubdefines.PythonError("recvfail2")
Ejemplo n.º 4
0
 def run(self):
     while self.m_bConnected:
         try:
             sData = self.m_oSocket.recv(1024*1024)
             if(sData == 0):continue
             #self.m_oSocket.send(json.dumps({"ranks":[{"name":"liusai","score":150},{"name":"caifan","score":10}]}))
             #print "recvdata:",sData
         except:
             self.Disconnected("recvfail")
             return
         try:
             self.Recv(sData)
         except:
             pubdefines.PythonError("recvfail2")
 def Release(self):
     try:
         self.m_bConnected = False
         self.m_oSocket.close()
     except:
         pubdefines.PythonError()