Example #1
0
        /// <summary>
        /// Processes the opt out packet being sent by devices when they leave the network.
        /// </summary>
        /// <param name="optOut">The opt out packet that was recieved.</param>
        private void ProcessOptOut(TCNetOptOut optOut)
        {
            TCNetDevice device;

            if (devices.TryGetValue(optOut.NetworkID, out device))
            {
                devices.Remove(optOut.NetworkID);
                RaiseDeviceLost(device);
            }
        }
Example #2
0
        /// <summary>
        /// Constructs and broadcasts the OptIn packet to all devices on the network.
        /// </summary>
        /// <remarks>
        /// This should be sent when the device is being shutdown.
        /// </remarks>
        protected void SendOptOut()
        {
            IPEndPoint localEndpoint = (IPEndPoint)nodeSocket.LocalEndPoint;

            TCNetOptOut offerPacket = new TCNetOptOut();

            offerPacket.NodeCount        = 1;
            offerPacket.NodeListenerPort = (ushort)localEndpoint.Port;

            Broadcast(managementSocket, offerPacket);
        }