Exemple #1
0
        /// <summary>
        /// Gets ids register command for the identified object in the bytes stack message
        /// </summary>
        /// <param name="commandType">Command type</param>
        /// <param name="identifiedObject">Identified object which is command target</param>
        /// <returns>Register command in bytes stack</returns>
        private Message GetCommandMessage(IdsRegisterCommandType commandType, IIdentifiedObject identifiedObject)
        {
            var bytesStack = new BytesStack();
            var id         = ResolveId(identifiedObject);

            if (id == null)
            {
                throw new ArgumentException("Usage of the unregistered identified object.");
            }
            bytesStack.PushInt(id.Value, BytesPerId);
            bytesStack.PushString(identifiedObject.Key);
            bytesStack.PushInt((int)commandType, BytesPerCommandType);
            return(new Message(Key, bytesStack, MessageType.ReliableOrdered));
        }
Exemple #2
0
        /// <summary>
        /// Gets ids register command for the identified object in the bytes stack message
        /// </summary>
        /// <param name="commandType">Command type</param>
        /// <param name="identifiedObject">Identified object which is command target</param>
        /// <returns>Register command in bytes stack</returns>
        private DistributedMessage GetCommandMessage(
            IdsRegisterCommandType commandType,
            IIdentifiedObject identifiedObject)
        {
            var id = ResolveId(identifiedObject);

            if (id == null)
            {
                throw new ArgumentException("Usage of the unregistered identified object.");
            }

            var message =
                MessagesPool.Instance.GetMessage(
                    BytesPerId + BytesStack.GetMaxByteCount(identifiedObject.Key) + BytesPerCommandType);

            message.AddressKey = Key;
            message.Content.PushInt(id.Value, BytesPerId);
            message.Content.PushString(identifiedObject.Key);
            message.Content.PushInt((int)commandType, BytesPerCommandType);
            message.Type = DistributedMessageType.ReliableOrdered;
            return(message);
        }