private void read() { try { LoginClient.StateObject stateObject = new LoginClient.StateObject(); stateObject.workSocket = this._client; this._client.BeginReceive(stateObject.buffer, 0, 8096, SocketFlags.None, new AsyncCallback(this.OnReceiveCallback), (object)stateObject); } catch { this.Close(0, true); } }
private void OnReceiveCallback(IAsyncResult ar) { LoginClient.StateObject asyncState = (LoginClient.StateObject)ar.AsyncState; try { 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, true); } else { this.RunPacket(numArray2, numArray1); this.checkoutN(buffer, FirstLength); new Thread(new ThreadStart(this.read)).Start(); } } catch (ObjectDisposedException ex) { } catch { this.Close(0, true); } }