Esempio n. 1
0
        /// <summary>
        /// Set property value.
        /// </summary>
        /// <param name="index">Zero-based property index.</param>
        /// <param name="value">Value</param>
        /// <returns>Indicator when the property is set.</returns>
        internal AsyncReply _Set(byte index, object value)
        {
            if (index >= properties.Length)
            {
                return(null);
            }

            var reply = new AsyncReply();

            var parameters = Codec.Compose(value, connection);

            connection.SendRequest(Packets.IIPPacket.IIPPacketAction.SetProperty, instanceId, index, parameters).Then((res) =>
            {
                // not really needed, server will always send property modified, this only happens if the programmer forgot to emit in property setter
                properties[index] = value;
                reply.Trigger(null);
            });

            return(reply);
        }