Exemplo n.º 1
0
        public bool RequestServerVersion()
        {
            ByteArray byteArray = new ByteArray(5);

            byteArray.writeByte((sbyte)this._make_sgn_pkg_header(16u));
            byteArray.writeUnsignedInt(0u);
            int num = (int)this.OSend(byteArray.data, byteArray.length);

            return(true);
        }
Exemplo n.º 2
0
        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);
                    }
                }
            }
        }