protected void CheckConnect(ClientDescriptor clientDescriptor)
 {
   // Check if client is attached and connect if it is an attached client
   string clientSystemId = clientDescriptor.MPFrontendServerUUID;
   lock (_networkTracker.SharedControlPointData.SyncObj)
   {
     if (!_attachedClientSystemIds.Contains(clientSystemId))
       return;
     if (_clientConnections.ContainsKey(clientSystemId))
       return;
   }
   DeviceConnection connection;
   try
   {
     connection = _controlPoint.Connect(clientDescriptor.ClientDeviceDescriptor.RootDescriptor, clientSystemId,
         UPnPExtendedDataTypes.ResolveDataType);
   }
   catch (Exception e)
   {
     ServiceRegistration.Get<ILogger>().Warn(
         "UPnPServerControlPoint: Error connecting to UPnP MP2 frontend server '{0}'", e, clientSystemId);
     return;
   }
   try
   {
     ClientConnection clientConnection = new ClientConnection(_controlPoint, connection, clientDescriptor);
     lock (_networkTracker.SharedControlPointData.SyncObj)
       _clientConnections.Add(clientDescriptor.MPFrontendServerUUID, clientConnection);
     clientConnection.ClientDeviceDisconnected += OnClientDisconnected;
   }
   catch (Exception e)
   {
     ServiceRegistration.Get<ILogger>().Warn(
         "UPnPServerControlPoint: Error connecting to services of UPnP MP2 frontend server '{0}'", e, clientSystemId);
     _controlPoint.Disconnect(connection);
     return;
   }
   InvokeClientConnected(clientDescriptor);
 }
예제 #2
0
 protected void InvokeClientDeviceDisconnected(ClientConnection connection)
 {
   ClientDeviceDisconnectedDlgt dlgt = ClientDeviceDisconnected;
   if (dlgt != null)
     dlgt(this);
 }
 void OnClientDisconnected(ClientConnection clientConnection)
 {
   ClientDescriptor descriptor = clientConnection.Descriptor;
   lock (_networkTracker.SharedControlPointData.SyncObj)
   {
     string deviceUuid = descriptor.MPFrontendServerUUID;
     if (!_clientConnections.ContainsKey(deviceUuid))
       return;
     _clientConnections.Remove(deviceUuid);
   }
   InvokeClientDisconnected(descriptor);
 }