Exemple #1
0
        public void AttachClient(string clientSystemId)
        {
            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();

            try
            {
                using (IDbCommand command = ClientManager_SubSchema.InsertAttachedClientCommand(transaction, clientSystemId, null, null))
                    command.ExecuteNonQuery();
                transaction.Commit();
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("ClientManager: Error attaching client '{0}'", e, clientSystemId);
                transaction.Rollback();
                throw;
            }
            ServiceRegistration.Get <ILogger>().Info("ClientManager: Client with system ID '{0}' attached", clientSystemId);
            // Establish the UPnP connection to the client, if available in the network
            IDictionary <string, MPClientMetadata> attachedClients = ReadAttachedClientsFromDB();

            lock (_syncObj)
                _attachedClients = attachedClients;
            _controlPoint.AddAttachedClient(clientSystemId);
            ClientManagerMessaging.SendClientAttachmentChangeMessage(ClientManagerMessaging.MessageType.ClientAttached, clientSystemId);
        }
Exemple #2
0
        public void DetachClientAndRemoveShares(string clientSystemId)
        {
            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();

            try
            {
                using (IDbCommand command = ClientManager_SubSchema.DeleteAttachedClientCommand(transaction, clientSystemId))
                    command.ExecuteNonQuery();

                IMediaLibrary mediaLibrary = ServiceRegistration.Get <IMediaLibrary>();
                mediaLibrary.DeleteMediaItemOrPath(clientSystemId, null, true);
                mediaLibrary.RemoveSharesOfSystem(clientSystemId);

                transaction.Commit();
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("ClientManager: Error detaching client '{0}'", e, clientSystemId);
                transaction.Rollback();
                throw;
            }
            ServiceRegistration.Get <ILogger>().Info("ClientManager: Client with system ID '{0}' detached", clientSystemId);
            // Last action: Remove the client from the collection of attached clients and disconnect the client connection, if connected
            _attachedClients = ReadAttachedClientsFromDB();
            _controlPoint.RemoveAttachedClient(clientSystemId);
            ClientManagerMessaging.SendClientAttachmentChangeMessage(ClientManagerMessaging.MessageType.ClientDetached, clientSystemId);
        }
Exemple #3
0
 protected void CompleteClientConnection(ClientDescriptor client)
 {
     if (!ValidateAttachmentState(client))
     {
         return;
     }
     UpdateClientSystem(client.MPFrontendServerUUID, client.System, client.ClientName);
     ClientManagerMessaging.SendConnectionStateChangedMessage(ClientManagerMessaging.MessageType.ClientOnline, client);
 }
Exemple #4
0
 void OnClientDisconnected(ClientDescriptor client)
 {
     UpdateClientSetOffline(client.MPFrontendServerUUID);
     ClientManagerMessaging.SendConnectionStateChangedMessage(ClientManagerMessaging.MessageType.ClientOffline, client);
 }
Exemple #5
0
 public void DetachClient(Guid clientId)
 {
     ClientManagerMessaging.SendClientAttachmentChangeMessage(ClientManagerMessaging.MessageType.ClientDetached, clientId.ToString());
 }