import socket, ssl, threading, struct protocolVer = 1 sock = None authed = False sessionKey = b'\0'*16 nextID = 1 lastReceivedPacketID = 0 packetCache = [] packetLock = threading.Lock() class Packet: def __init__(self, type, data): global nextID self.type = type self.data = data if (type & 0x8000) == 0: self.id = nextID nextID = nextID + 1 def sendOverWire(self): header = struct.pack(' bufsize: break type, reserved, size = struct.unpack_from(' bufsize: break pos += 8 with packetLock: if ((type & 0x8000) == 0): pid, lastReceivedByServer = struct.unpack_from('