public void Process() { double num = (double)CCTime.getTickMillisec(); this._onProcess(); double procTm = (double)CCTime.getTickMillisec() - num; _MsgProfilerMgr.inst.getMsgProfiler(this.msgType, this.msgID).onProc(procTm); }
public virtual void process(float tmSlice) { this._conn.onProcess(); long tickMillisec = CCTime.getTickMillisec(); while (this._MsgVec.Count > 0) { MsgProcesser msgProcesser = ArrayUtil.arrayPopFront <MsgProcesser>(this._MsgVec); msgProcesser.Process(); msgProcesser.Dispose(); this._netMgr.deleteMSGProcesser(msgProcesser); long tickMillisec2 = CCTime.getTickMillisec(); bool flag = tickMillisec2 - tickMillisec > 10L; if (flag) { break; } } }
public void onProcess() { bool flag = !this._sock.Connected; if (flag) { bool isConnected = this._isConnected; if (isConnected) { this._isConnected = false; this._cb.onConnectionClose(); } } else { bool isConnecting = this._isConnecting; if (isConnecting) { this._isConnecting = false; this._isConnected = true; this._cb.onConnect(); Variant variant = new Variant(); variant["uid"] = this._uid; variant["tkn"] = this._token; variant["clnt"] = this._clnt; this.PSendTPKG(2u, variant); } long tickMillisec = CCTime.getTickMillisec(); bool flag2 = tickMillisec - this._last_hb_send_time > (long)((ulong)this._hb_interval_val); if (flag2) { bool connected = this._sock.Connected; if (connected) { this._last_hbs_time_ms = tickMillisec; ByteArray byteArray = new ByteArray(); byteArray.writeByte((sbyte)this._make_sgn_pkg_header(0u)); byteArray.writeUnsignedInt((uint)(this._last_server_tm_ms + (ulong)(this._last_hbs_time_ms - this._last_hbr_time_ms))); this._flushData(byteArray); byteArray.length = 0; this._last_hb_send_time = tickMillisec; } } try { bool flag3 = this._sock.Available > 0; if (flag3) { bool flag4 = this._recvBuffer.position > 0; if (flag4) { this._recvBuffer.skip(this._recvBuffer.position); this._recvBuffer.position = 0; } this._recvBuffer.capcity = this._recvBuffer.length + this._sock.Available + 4096; int num = this._sock.Receive(this._recvBuffer.data, this._recvBuffer.length, this._sock.Available, SocketFlags.None); this._recvBuffer.length = this._recvBuffer.length + num; this._tryUnpackPackage(); } } catch (SocketException ex) { bool flag5 = ex.ErrorCode != 10035; if (flag5) { this._cb.onError(ex.Message); } } } }
private void _type_package_cb_fn(Variant pkg_data, ByteArray tmp) { bool flag = ConnectionImpl.s_bShowNetLog; if (flag) { Debug.Log("底层 type接收到消息包 -- ID " + pkg_data.dump()); } bool flag2 = pkg_data["cmd"]._uint == 2u; if (flag2) { this._isLogedin = (pkg_data["data"]["res"]._int == 1); bool isLogedin = this._isLogedin; if (isLogedin) { this._server_tm_diff_ms = (long)((ulong)(pkg_data["data"]["time"]._uint * 1000u) - (ulong)CCTime.getCurTimestampMS()); this._server_tm_diff_s = (long)((ulong)pkg_data["data"]["time"]._uint - (ulong)((long)CCTime.getCurTimestamp())); this._cb.onLogin(pkg_data["data"]); } else { DebugTrace.add(Define.DebugTrace.DTT_ERR, "Login failed: " + pkg_data["data"]["res"]._int); } } else { this._cb.onTPKG(pkg_data["cmd"]._uint, pkg_data["data"]); } }
protected void _tryUnpackPackage() { int num = 0; while (this._recvBuffer.bytesAvailable > 0) { ByteArray byteArray = new ByteArray(); num++; uint num2 = (uint)this._recvBuffer.readUnsignedByte(); uint num3 = num2 & 192u; bool flag = num3 == 0u; if (flag) { bool flag2 = num2 == 0u; if (flag2) { bool flag3 = this._recvBuffer.bytesAvailable < 4; if (flag3) { this._recvBuffer.position--; break; } this._last_server_tm_ms = (ulong)this._recvBuffer.readUnsignedInt(); this._last_hbr_time_ms = CCTime.getTickMillisec(); this._latency_ms = this._last_hbr_time_ms - this._last_hbs_time_ms; bool flag4 = this._min_last_server_tm_ms == 0uL; if (flag4) { this._min_last_server_tm_ms = this._last_server_tm_ms; this._min_last_hbr_time_ms = this._last_hbr_time_ms; this._min_latency_ms = this._latency_ms; } bool flag5 = this._latency_ms < this._min_latency_ms; if (flag5) { this._min_last_server_tm_ms = this._last_server_tm_ms; this._min_last_hbr_time_ms = this._last_hbr_time_ms; this._min_latency_ms = this._latency_ms; } this._cb.onHBRecv(); } } else { bool flag6 = num3 == 64u; if (flag6) { bool flag7 = this._recvBuffer.bytesAvailable < 1; if (flag7) { this._recvBuffer.position--; break; } uint num4 = (num2 & 31u) << 8; num4 |= (uint)this._recvBuffer.readUnsignedByte(); bool flag8 = (long)this._recvBuffer.bytesAvailable < (long)((ulong)(num4 - 2u)); if (flag8) { this._recvBuffer.position -= 2; break; } this._recvBuffer.readBytes(byteArray, 0, (int)(num4 - 2u)); bool flag9 = this._is_pkg_compressed(num2); if (flag9) { byteArray.uncompress(); } Variant pkg_data = this._pack.UnpackRPCPackage(byteArray.data, byteArray.length); this._rpc_package_cb_fn(pkg_data, byteArray); } else { bool flag10 = num3 == 128u; if (flag10) { bool flag11 = this._recvBuffer.bytesAvailable < 3; if (flag11) { this._recvBuffer.position--; break; } uint num4 = (num2 & 31u) << 24; num4 |= (uint)this._recvBuffer.readUnsignedByte(); num4 |= (uint)((uint)this._recvBuffer.readUnsignedShort() << 8); bool flag12 = (long)this._recvBuffer.bytesAvailable < (long)((ulong)(num4 - 4u)); if (flag12) { this._recvBuffer.position -= 4; break; } this._recvBuffer.readBytes(byteArray, 0, (int)(num4 - 4u)); bool flag13 = this._is_pkg_compressed(num2); if (flag13) { byteArray.uncompress(); } Variant pkg_data = this._pack.UnpackTypePackage(byteArray.data, byteArray.length); this._type_package_cb_fn(pkg_data, byteArray); } else { bool flag14 = num3 == 192u; if (!flag14) { break; } bool flag15 = this._recvBuffer.bytesAvailable < 3; if (flag15) { this._recvBuffer.position--; break; } uint num4 = (num2 & 31u) << 24; num4 |= (uint)this._recvBuffer.readUnsignedByte(); num4 |= (uint)((uint)this._recvBuffer.readUnsignedShort() << 8); bool flag16 = (long)this._recvBuffer.bytesAvailable < (long)((ulong)(num4 - 4u)); if (flag16) { this._recvBuffer.position -= 4; break; } this._recvBuffer.readBytes(byteArray, 0, (int)(num4 - 4u)); bool flag17 = this._is_pkg_compressed(num2); if (flag17) { byteArray.uncompress(); } Variant pkg_data = this._pack.UnpackFullTypePackage(byteArray.data, byteArray.length); this._full_type_pacakge_cb_fn(pkg_data, byteArray); } } } } }