private void OnReceiveCallback(IAsyncResult ar) { try { GameClient.StateObject asyncState = (GameClient.StateObject)ar.AsyncState; int length = asyncState.workSocket.EndReceive(ar); if (length <= 0) { return; } byte[] buffer = new byte[length]; Array.Copy((Array)asyncState.buffer, 0, (Array)buffer, 0, length); int FirstLength = (int)BitConverter.ToUInt16(buffer, 0) & (int)short.MaxValue; byte[] numArray1 = new byte[FirstLength + 2]; Array.Copy((Array)buffer, 2, (Array)numArray1, 0, numArray1.Length); this.lastCompleteBuffer = buffer; byte[] numArray2 = ComDiv.decrypt(numArray1, this.Shift); if (!this.CheckSeed(numArray2, true)) { this.Close(0, false); } else { this.RunPacket(numArray2, numArray1); this.checkoutN(buffer, FirstLength); new Thread(new ThreadStart(this.read)).Start(); } } catch { this.Close(0, false); } }
private void read() { try { GameClient.StateObject stateObject = new GameClient.StateObject(); stateObject.workSocket = this._client; this._client.BeginReceive(stateObject.buffer, 0, 8096, SocketFlags.None, new AsyncCallback(this.OnReceiveCallback), (object)stateObject); } catch { this.Close(0, false); } }