コード例 #1
0
        public void CanStoreByte()
        {
            var blob = new byte[1];
            var span = StoreOps.StoreByte(blob, 5);

            Assert.True(span.IsEmpty);
            Assert.Equal(5, blob[0]);
        }
コード例 #2
0
        /// <summary>
        /// Construct the reply to <see cref="TurnOnArgs{A}"/>. In line of principle you could not-reply to
        /// some devices as they could be mangled by somebody else but... for the time being it's just a matter
        /// of giving back the server address to perform unicast packet transmissions.
        /// </summary>
        /// <param name="reachme">An unicast address the device who originally talked can contact me.</param>
        /// <param name="identificator">Currently unused.</param>
        /// <param name="deviceSpecific">Currently unused.</param>
        /// <returns>
        /// Blob to send over the wire. I won't touch it anymore. If I don't want to deal with this device
        /// (maybe it belongs to another server) I will return null and you send nothing to it.
        /// </returns>
        static internal byte[]? Welcome(IPAddress reachme, byte[] identificator, byte[] deviceSpecific)
        {
            var addrBlob = reachme.GetAddressBytes();
            var blob     = new byte[1 + 1 + addrBlob.Length];
            var store    = StoreOps.StoreKind(blob, OutgoingKind.ServerAddress);

            store = StoreOps.StoreByte(store, 0); // this is really a bitflag of features. For the time being it must be zero so no big deal
            store = StoreOps.StoreByteArray(store, addrBlob);
            ThrowIfNotFullyConsumed(store);
            return(blob);
        }