示例#1
0
        private void PushService(FPData quest)
        {
            lock (self_locker) {
                FPClient self = this;
                this._psr.Service(quest, (payload, exception) => {
                    FPData data = new FPData();
                    data.SetFlag(quest.GetFlag());
                    data.SetMtype(0x2);
                    data.SetSeq(quest.GetSeq());
                    data.SetSS(exception ? 1 : 0);

                    if (quest.GetFlag() == 0)
                    {
                        data.SetPayload(Convert.ToString(payload));
                    }

                    if (quest.GetFlag() == 1)
                    {
                        data.SetPayload((byte[])payload);
                    }

                    self.SendQuest(data);
                });
            }
        }
        public FPData PeekHead(byte[] bytes)
        {
            if (bytes.Length < 12)
            {
                return(null);
            }

            FPData peek = new FPData();

            peek.SetMagic(this.GetByteArrayRange(bytes, 0, 3));
            peek.SetVersion(Array.IndexOf(FPConfig.FPNN_VERSION, bytes[4]));

            if (bytes[5] == FPConfig.FP_FLAG[0])
            {
                peek.SetFlag(0);
            }

            if (bytes[5] == FPConfig.FP_FLAG[1])
            {
                peek.SetFlag(1);
            }

            peek.SetMtype(Array.IndexOf(FPConfig.FP_MESSAGE_TYPE, bytes[6]));
            peek.SetSS(bytes[7]);
            peek.SetPsize((int)BitConverter.ToUInt32(this.GetByteArrayRange(bytes, 8, 11), 0));

            return(peek);
        }
示例#3
0
        public void SendNotify(FPData data)
        {
            if (data != null && data.GetMtype() != 0x0)
            {
                data.SetMtype(0x0);
            }

            byte[] buf = this._pkg.EnCode(data);
            buf = this._cry.EnCode(buf);

            if (buf != null)
            {
                this._sock.Write(buf);
            }
        }