Beispiel #1
0
 public void HeartBeat()
 {
     if (isConnected)
     {
         last_hbs_time_ms = APP.Instance.timer.getTimer();
         MsgStream ms = new MsgStream();
         ms.WriteBytes((byte)Protocol_base._make_sgn_pkg_header(0x00));
         ms.WriteBytes((uint)(last_server_tm_ms + (last_hbs_time_ms - last_hbr_time_ms)));
         Write(ms.OutByte());
     }
 }
Beispiel #2
0
        private void onData(int length)
        {
            leftRecieveDataLength += length;
            MsgStream ms = new MsgStream();

            ms.setReadIndex(offSet);
            byte[] temp = null;
            while (leftRecieveDataLength > 0)
            {
                if (msgLength == 0)
                {
                    if (leftRecieveDataLength < HEAD_LEN)
                    {
                        break;
                    }
                    ms.Read(readData, ref msgLength);
                    leftRecieveDataLength -= 4;
                    offSet += 4;
                    if (msgLength == 0)
                    {
                        break;
                    }
                }
                if (leftRecieveDataLength < msgLength)
                {
                    break;
                }
                int msgid = 0;
                ms.Read(readData, ref msgid);
                msgLength             -= 4;
                leftRecieveDataLength -= 4;
                offSet += 4;
                if (msgLength > 0)
                {
                    ms.Read(readData, msgLength, ref temp);
                }
                DispatchCmd(msgid, temp);
                leftRecieveDataLength -= msgLength;
                offSet   += msgLength;
                msgLength = 0;
            }
        }