Advertisement
Guest User

Untitled

a guest
May 25th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. def serve_client(conn, addr, id, sid):
  2. ready = select.select([conn], [], [], 0.1)
  3. if ready[0]:
  4. req = conn.recv(1024)
  5. if "policy-file-request" in req:
  6. print "policy file"
  7. conn.send("<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>\x00")
  8. conn.close()
  9. return
  10. clients[id] = Client(conn, id, sid, addr)
  11. req = req.split("\x00")[:-1]
  12. i = 0
  13. ii = len(req)
  14. while i < ii:
  15. p = SocketMessage(req[i])
  16. cmd = p.bitReadUnsignedInt(16)
  17. c = p.bitReadUnsignedInt(5)
  18. cc = p.bitReadUnsignedInt(5)
  19. clients[id].parsePacket(c, cc, p)
  20. i+=1
  21.  
  22. conn.setblocking(0)
  23.  
  24. while 1:
  25. for pv in range(100):
  26. if chrono[id][pv] != 0 and chrono[id][pv] < time.time():
  27. chrono[id][pv] = 0
  28.  
  29. if chrono_king[id] > 0 and chrono_king[id] < time.time():
  30. king[id] = 1
  31. chrono_king[id] = 0
  32.  
  33.  
  34. ready = select.select([conn], [], [], 0.01)
  35. if ready[0]:
  36. data = conn.recv(1024)
  37. if not data: break
  38. req = data.split("\x00")[:-1]
  39. i = 0
  40. ii = len(req)
  41. while i < ii:
  42. p = SocketMessage(req[i])
  43. cmd = p.bitReadUnsignedInt(16)
  44. c = p.bitReadUnsignedInt(5)
  45. cc = p.bitReadUnsignedInt(5)
  46. clients[id].parsePacket(c, cc, p)
  47. i+=1
  48. if clients[id]:
  49. if clients[id].mapid and clients[id].mapid in MapList:
  50. if i in MapList[clients[id].mapid]:
  51. MapList[clients[id].mapid].remove(i)
  52. p2 = clients[id].SocketMessage(5, 2)
  53. p2.bitWriteUnsignedInt(GlobalProperties.BIT_USER_PID, clients[id].pid)
  54. p2.bitWriteUnsignedInt(GlobalProperties.BIT_METHODE_ID, 33)
  55. sendAll(clients[id].mapid, p2)
  56. clients[id] = ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement