/// <summary>
 /// The method that unsubscribes the pipe device from all events, stops direct MetaPubSub server
 /// and remove its pairing with the relative pipe device.
 /// </summary>
 /// <param name="pipeDevice">The pipe device that must unsubscribe from all events.</param>
 /// <param name="pubSub">The key through which you want to remove the pipe device from the dictionary.</param>
 void DisposePipeDevicePair(IPipeDevice pipeDevice, IMetaPubSub pubSub)
 {
     if (pubSub != null)
     {
         pipeDevice.DeviceStateChanged -= RemoteConnection_DeviceStateChanged;
         pubSub.StopServer();
         RemotePipeDevicesDictionary.Remove(pubSub);
     }
 }
 void SubscribeToPipeDeviceEvents(IPipeDevice pipeDevice, IMetaPubSub pubSub)
 {
     RemotePipeDevicesDictionary.Add(pubSub, pipeDevice);
     pipeDevice.DeviceStateChanged += RemoteConnection_DeviceStateChanged;
 }
        /// <summary>
        /// Remove the pipe device.
        /// </summary>
        /// <param name="pipeDevice">The pipe device, that must be removed.</param>
        public void RemovePipeDevice(IPipeDevice pipeDevice)
        {
            var pubSub = RemotePipeDevicesDictionary.Where(p => p.Value == pipeDevice).FirstOrDefault().Key;

            DisposePipeDevicePair(pipeDevice, pubSub);
        }