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); }
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); }); } }