public override byte[] OnRecv(byte[] data, int length)
        {
            for (int i = 0; i < length; i++)
            {
                input.Add(data[i]);
            }
            while (input.Length >= 6)
            {
                if (needDecode && SS_Hash != null)
                {
                    Decode(input);
                    needDecode = false;
                }
                input.pos = 0;
                ushort len = input.GetWord();
                if (input.Length < len + 2)
                {
                    return(null);
                }

                needDecode = true;
                data       = input.GetArray(4, len - 2);
                OP code = (OP)(input[2] + (input[3] << 8));
                input.Remove(0, len + 2);
                SetInput(data);

                RunMsg(code);
            }
            return(null);
        }
Example #2
0
        public override void RunSend()
        {
            if (result == null)
            {
                return;
            }
            int sz = sock.Send(result);

            if (sz <= 0)
            {
                Dispose();
                return;
            }
            if (result.Length > sz)
            {
                result.Remove(0, sz);
                return;
            }
            result = null;
            return;
        }