示例#1
0
        public IdpPacket ProcessPayload(UInt16 nodeAddress, IdpPacket packet)
        {
            var incoming = new IncomingTransaction(packet);
            var outgoing = new OutgoingTransaction(0xA000, incoming.TransactionId, IdpCommandFlags.None);

            if (_commandHandlers.ContainsKey(incoming.CommandId))
            {
                outgoing.Write((byte)IdpResponseCode.OK);
                outgoing.Write(incoming.CommandId);

                var responseCode = _commandHandlers[incoming.CommandId](incoming, outgoing);

                if (incoming.Flags.HasFlag(IdpCommandFlags.ResponseExpected))
                {
                    outgoing.WithResponseCode(responseCode);

                    return(outgoing.ToPacket(nodeAddress, packet.Source));
                }
            }
            else
            {
                outgoing.Write((byte)IdpResponseCode.UnknownCommand);
                outgoing.Write(incoming.CommandId);

                return(outgoing.ToPacket(nodeAddress, packet.Source));
            }

            return(null);
        }
示例#2
0
        public IdpResponse(IncomingTransaction incomingTransaction)
        {
            Transaction = incomingTransaction;

            ResponseCode = incomingTransaction.Read <IdpResponseCode>();

            ResponseId = incomingTransaction.Read <UInt16>();
        }