public OuterCommandCall(OuterCommand command, Message callMessage,
                                Action <OuterCommandCall> callAction, Action <OuterCommandCall> callBufferAction)
        {
            m_callAction       = callAction;
            m_callBufferAction = callBufferAction;
            Command            = command;
            CallMessage        = callMessage;

            m_wasPerformed = false;
            m_spinWait     = new SpinWait();
            Reply          = null;
            lock (m_lock)
                CallId = m_nextId++;
        }
Beispiel #2
0
        public static OuterCommand DecodeCommandInit(Int32 identity, IList <Byte[]> message)
        {
            Int32 index = 0;

            var command = new OuterCommand
            {
                Messenger   = message[index++][0],
                CommandId   = BitConverter.ToInt32(message[index++], 0),
                Name        = Encoding.ASCII.GetString(message[index++]),
                Description = Encoding.ASCII.GetString(message[index++]),
                Usage       = (CommandUsage)message[index++][0],
                Node        = identity,
            };
            var msgDesc = GetPart();

            if (msgDesc is null)
            {
                index++;
            }
            var replDesc = GetPart();

            command.ReplyDescription   = replDesc;
            command.RequestDescription = msgDesc;

            return(command);

            List <MessagePartDescription> GetPart()
            {
                Byte[] name;
                MessagePartDescription msgPart;

                var part = new Lazy <List <MessagePartDescription> >();

                while (message.Count > index && (name = message[index++]).Length != 0)
                {
                    msgPart = new MessagePartDescription
                    {
                        Name = Encoding.ASCII.GetString(name),
                        Type = (MessageValueType)message[index++][0]
                    };

                    part.Value.Add(msgPart);
                }

                return(part.IsValueCreated ? part.Value : null);
            }
        }