/// <summary>
 /// Forward a message to dead-letters (and wrap it in a contextual dead-letter
 /// structre)
 /// </summary>
 /// <param name="message">Dead letter message</param>
 /// <param name="ex">Exception that caused the dead-letter</param>
 public static Unit dead(object message, Exception ex, SystemName system = default(SystemName)) =>
     tell(
         ActorContext.System(system).DeadLetters,
         DeadLetter.create(
             Sender,
             Self,
             ex,
             message
     ));
 /// <summary>
 /// Forward the current message to dead-letters (and wrap it in a contextual dead-letter
 /// structre)
 /// </summary>
 /// <param name="reason">Reason for the dead-letter</param>
 public static Unit dead(string reason, SystemName system = default(SystemName)) =>
     tell(
         ActorContext.System(system).DeadLetters,
         DeadLetter.create(
             Sender,
             Self,
             reason,
             ActorContext.Request.CurrentMsg
     ));
 /// <summary>
 /// Forward a message to dead-letters (and wrap it in a contextual dead-letter
 /// structre)
 /// </summary>
 /// <param name="message">Dead letter message</param>
 /// <param name="reason">Reason for the dead-letter</param>
 public static Unit dead(object message, string reason, SystemName system = default(SystemName)) =>
     tell(
         ActorContext.System(system).DeadLetters, 
         DeadLetter.create(
             Sender, 
             Self,
             reason, 
             message
     ));
 /// <summary>
 /// Forward the current message to dead-letters (and wrap it in a contextual dead-letter
 /// structre)
 /// </summary>
 /// <param name="ex">Exception that caused the dead-letter</param>
 public static Unit dead(Exception ex, SystemName system = default(SystemName)) =>
     tell(
         ActorContext.System(system).DeadLetters,
         DeadLetter.create(
             Sender,
             Self,
             ex,
             ActorContext.Request.CurrentMsg
     ));
        static RemoteMessageDTO FixupPathsSystemPrefix(RemoteMessageDTO dto, SystemName system)
        {
            if (dto == null) return null;

            // Fix up the paths so we know what system they belong to.
            dto.ReplyTo = String.IsNullOrEmpty(dto.ReplyTo) || dto.ReplyTo.StartsWith("//") ? dto.ReplyTo : $"//{system}{dto.ReplyTo}";
            dto.Sender = String.IsNullOrEmpty(dto.Sender) || dto.Sender.StartsWith("//") ? dto.Sender : $"//{system}{dto.Sender}";
            dto.To = String.IsNullOrEmpty(dto.To) || dto.To.StartsWith("//") ? dto.To : $"//{system}{dto.To}";
            return dto;
        }
        /// <summary>
        /// Start up the process log
        /// </summary>
        /// <param name="processNameOverride">Override the default process name</param>
        /// <param name="logViewMax">Size of the log 'window'</param>
        public static Unit startup(Option<ProcessName> processNameOverride, int logViewMax = 200, SystemName system = default(SystemName))
        {
            if (processId.IsValid) return unit;
            lock (sync)
            {
                if (processId.IsValid) return unit;

                processName = processNameOverride.IfNone("process-log");
                processId = spawn<State, ProcessLogItem>(processName, () => setup(logViewMax), inbox);

                deadLetterSub = subscribe<DeadLetter>(DeadLetters(system), msg => tellWarning(msg.ToString()));
                errorSub = subscribe<Exception>(Errors(system), e => tellError(e));
            }

            return unit;
        }
        public SessionManager(Option<ICluster> cluster, SystemName system, ProcessName nodeName, VectorConflictStrategy strategy)
        {
            this.cluster = cluster;
            this.system = system;
            this.nodeName = nodeName;

            Sync = new SessionSync(system, nodeName, strategy);

            cluster.Iter(c =>
            {
                notify = c.SubscribeToChannel<SessionAction>(SessionsNotify).Subscribe(act => Sync.Incoming(act));

                var now = DateTime.UtcNow;

                // Look for stranded sessions that haven't been removed properly.  This is done once only
                // on startup because the systems should be shutting down sessions on their own.  This just
                // catches the situation where an app-domain died without shutting down properly.
                c.QuerySessionKeys()
                 .Map(key =>
                    from ts in c.GetHashField<long>(key, LastAccessKey)
                    from to in c.GetHashField<int>(key, TimeoutKey)
                    where new DateTime(ts) < now.AddSeconds(to * 2) // Multiply by 2, just to catch genuine non-active sessions
                    select c.Delete(key))
                 .Iter(id => { });

                // Remove session keys when an in-memory session ends
                ended = SessionEnded.Subscribe(sid => Stop(sid));

                touch = Sync.Touched.Subscribe(tup =>
                {
                    try
                    {
                        c.HashFieldAddOrUpdate(SessionKey(tup.Item1), LastAccessKey, DateTime.UtcNow.Ticks);
                        c.PublishToChannel(SessionsNotify, SessionAction.Touch(tup.Item1, system, nodeName));
                    }
                    catch(Exception e)
                    {
                        logErr(e);
                    }
                });
            });
        }
        public static Unit StopSystem(SystemName system)
        {
            lock (sync)
            {
                if(context == system)
                {
                    context = default(SystemName);
                }

                if(defaultSystem == system)
                {
                    defaultSystem = default(SystemName);
                }

                ActorSystem asystem = null;
                var token = new ShutdownCancellationToken(system);
                try
                {
                    Process.OnPreShutdown(token);
                }
                finally
                {
                    if (!token.Cancelled)
                    {
                        try
                        {
                            systems.TryGetValue(system, out asystem);
                            if (asystem != null)
                            {
                                asystem.Dispose();
                            }
                        }
                        finally
                        {
                            systems.TryRemove(system, out asystem);
                            Process.OnShutdown(system);
                        }
                    }
                }
                return unit;
            }
        }
        public static Unit StartSystem(SystemName system, Option<ICluster> cluster, AppProfile appProfile, ProcessSystemConfig config)
        {
            lock (sync)
            {
                if (systems.ContainsKey(system))
                {
                    throw new InvalidOperationException($"Process-system ({system}) already started");
                }

                var asystem = new ActorSystem(system, cluster, appProfile, config);
                systems.AddOrUpdate(system, asystem, (_, __) => asystem);
                try
                {
                    asystem.Initialise();

                    // Set the default system if the 'default: yes' setting is in the ProcessSystemConfig
                    defaultSystem = defaultSystem.IsValid
                        ? (from c in config.Cluster
                           where c.Default
                           select system)
                          .IfNone(defaultSystem)
                        : system;
                }
                catch
                {
                    systems.TryRemove(system, out asystem);
                    try
                    {
                        asystem.Dispose();
                    }
                    catch { }
                    throw;
                }
                return unit;
            }
        }
Beispiel #10
0
 protected void UpdateSharesList_NoLock(bool create)
 {
     lock (_syncObj)
         if (create)
         {
             _sharesList = new ItemsList();
         }
         else
         {
             _sharesList.Clear();
         }
     try
     {
         IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>();
         IContentDirectory        cd  = scm.ContentDirectory;
         IServerController        sc  = scm.ServerController;
         if (cd == null || sc == null)
         {
             return;
         }
         IRemoteResourceInformationService rris = ServiceRegistration.Get <IRemoteResourceInformationService>();
         ICollection <Share> allShares          = cd.GetShares(null, SharesFilter.All);
         IDictionary <string, ICollection <Share> > systems2Shares = new Dictionary <string, ICollection <Share> >();
         foreach (Share share in allShares)
         {
             ICollection <Share> systemShares;
             if (systems2Shares.TryGetValue(share.SystemId, out systemShares))
             {
                 systemShares.Add(share);
             }
             else
             {
                 systems2Shares[share.SystemId] = new List <Share> {
                     share
                 }
             };
         }
         ICollection <Guid>   importingShares = cd.GetCurrentlyImportingShares() ?? new List <Guid>();
         ICollection <string> onlineSystems   = sc.GetConnectedClients();
         onlineSystems = onlineSystems == null ? new List <string> {
             scm.HomeServerSystemId
         } : new List <string>(onlineSystems)
         {
             scm.HomeServerSystemId
         };
         foreach (KeyValuePair <string, ICollection <Share> > system2Shares in systems2Shares)
         {
             string systemId = system2Shares.Key;
             ICollection <Share> systemShares = system2Shares.Value;
             string systemName;
             string hostName;
             if (systemId == scm.HomeServerSystemId)
             {
                 systemName = scm.LastHomeServerName;
                 SystemName system = scm.LastHomeServerSystem;
                 hostName = system != null ? system.HostName : null;
             }
             else
             {
                 MPClientMetadata clientMetadata = ServerCommunicationHelper.GetClientMetadata(systemId);
                 if (clientMetadata == null)
                 {
                     systemName = null;
                     hostName   = null;
                 }
                 else
                 {
                     systemName = clientMetadata.LastClientName;
                     SystemName system = clientMetadata.LastSystem;
                     hostName = system != null ? system.HostName : null;
                 }
             }
             ListItem systemSharesItem = new ListItem(Consts.KEY_NAME, systemName);
             systemSharesItem.AdditionalProperties[Consts.KEY_SYSTEM]   = systemId;
             systemSharesItem.AdditionalProperties[Consts.KEY_HOSTNAME] = hostName;
             bool isConnected = onlineSystems.Contains(systemId);
             systemSharesItem.AdditionalProperties[Consts.KEY_IS_CONNECTED] = isConnected;
             ItemsList sharesItemsList = new ItemsList();
             foreach (Share share in systemShares)
             {
                 ListItem shareItem = new ListItem(Consts.KEY_NAME, share.Name);
                 shareItem.AdditionalProperties[Consts.KEY_SHARE] = share;
                 string resourcePathName;
                 try
                 {
                     bool     isFileSystemResource;
                     bool     isFile;
                     string   resourceName;
                     DateTime lastChanged;
                     long     size;
                     if (!rris.GetResourceInformation(share.SystemId, share.BaseResourcePath, out isFileSystemResource, out isFile, out resourcePathName, out resourceName, out lastChanged, out size))
                     {
                         // Error case: The path is invalid
                         resourcePathName = LocalizationHelper.Translate(Consts.RES_INVALID_PATH, share.BaseResourcePath);
                     }
                 }
                 catch (Exception) // NotConnectedException when remote system is not connected at all, UPnPDisconnectedException when remote system gets disconnected during the call
                 {
                     resourcePathName = share.BaseResourcePath.ToString();
                 }
                 shareItem.SetLabel(Consts.KEY_PATH, resourcePathName);
                 string categories = StringUtils.Join(", ", share.MediaCategories);
                 shareItem.SetLabel(Consts.KEY_MEDIA_CATEGORIES, categories);
                 UpdateShareImportState_NoLock(shareItem, importingShares.Contains(share.ShareId));
                 Share shareCopy = share;
                 shareItem.Command = new MethodDelegateCommand(() => ReImportShare(shareCopy));
                 shareItem.AdditionalProperties[Consts.KEY_REIMPORT_ENABLED] = isConnected;
                 sharesItemsList.Add(shareItem);
             }
             systemSharesItem.AdditionalProperties[Consts.KEY_SYSTEM_SHARES] = sharesItemsList;
             lock (_syncObj)
                 _sharesList.Add(systemSharesItem);
         }
     }
     finally
     {
         _sharesList.FireChange();
     }
 }
 public override int GetHashCode()
 {
     return(SystemName.GetHashCode());
 }
Beispiel #12
0
 /// <summary>
 /// Shutdown all processes on the specified process-system
 /// </summary>
 public static Unit shutdownSystem(SystemName system) =>
     ActorContext.StopSystem(system);
Beispiel #13
0
 public List <FileDescription> GetFileVersions(SystemName systemName)
 {
     return(GetFileVersionsString(systemName.ToString()));
 }
Beispiel #14
0
        internal static void ParseCommand(this string self)
        {
            string[] vars = self.Split();

            if (vars[0] == "/system")
            {
                if (vars[1] == "find")
                {
                    Logging.Print("\nPlaceholder\n");
                }
                else if (vars[1] == "coords")
                {
                    Console.WriteLine();
                    byte[] seed = vars[2].SystemCoordsToByteArray();
                    if (seed != null)
                    {
                        SystemName.FormatName(seed);
                    }
                }
                else if (vars[1] == "xcoords")
                {
                    Console.WriteLine();
                    byte[] seed = vars.SystemXCoordsToByteArray();
                    if (seed != null)
                    {
                        SystemName.FormatName(seed);
                    }
                }
                else if (vars[1] == "grfcoords")
                {
                    Console.WriteLine();
                    SystemName.FormatName(vars[2].Parse());
                }
                else
                {
                    Logging.PrintError("\nCould not parse input! Are you sure you typed the command correctly?\n");
                }
            }
            else if (vars[0] == "/region")
            {
                if (vars[1] == "find")
                {
                    Logging.Print("\nPlaceholder\n");
                }
                else if (vars[1] == "coords")
                {
                    Console.WriteLine();
                    byte[] seed = vars[2].RegionCoordsToByteArray();
                    if (seed != null)
                    {
                        RegionName.FormatName(seed);
                    }
                }
                else if (vars[1] == "xcoords")
                {
                    Console.WriteLine();
                    byte[] seed = vars.RegionXCoordsToByteArray();
                    if (seed != null)
                    {
                        RegionName.FormatName(seed);
                    }
                }
                else if (vars[1] == "grfcoords")
                {
                    Console.WriteLine();
                    RegionName.FormatName(vars[2].Parse());
                }
                else
                {
                    Logging.PrintError("\nCould not parse input! Are you sure you typed the command correctly?\n");
                }
            }
            else if (vars[0] == "debug")
            {
                Debug = !Debug;
                Logging.Print("Toggled debug mode!");
            }
            else
            {
                Logging.PrintError("\nCould not parse input! Are you sure you typed the command correctly?\n");
            }
        }
Beispiel #15
0
        public void Create_an_instance_with_NoName_default_value()
        {
            var sn = new SystemName();

            Check.That(sn.Value).IsEqualTo("NoName");
        }
Beispiel #16
0
        public void Create_an_instance_with_a_correct_value_and_retrieve_it()
        {
            var sn = new SystemName("MyValue");

            Check.That(sn.Value).IsEqualTo("MyValue");
        }
 public static ActorSystem System(SystemName system)
 {
     ActorSystem asys = null;
     if (system.IsValid)
     {
         if (systems.TryGetValue(system, out asys))
         {
             return asys;
         }
         else
         {
             return failwith<ActorSystem>($"Process-system does not exist {system}");
         }
     }
     else
     {
         return DefaultSystem;
     }
 }
Beispiel #18
0
        public MockMediaLibrary()
        {
            _miaManagement = MockCore.Management;

            _systemsOnline["mock"] = SystemName.GetLocalSystemName();
        }
Beispiel #19
0
        public override string ToString()
        {
            SystemName preferredLink = GetPreferredLink();

            return(string.Format("MP backend server '{0}' at host '{1}' (IP address: '{2}')", MPBackendServerUUID, preferredLink.HostName, preferredLink.Address));
        }
Beispiel #20
0
        protected void UpdateClientSetOnline(string clientSystemId, SystemName currentSytemName)
        {
            IMediaLibrary mediaLibrary = ServiceRegistration.Get <IMediaLibrary>();

            mediaLibrary.NotifySystemOnline(clientSystemId, currentSytemName);
        }
        //將LogInfo物件轉為Json,便於寫入NLog
        private RecordLogInfo ConvertLogInfo(string adAccount, LogType logType, EventLevel eventLevel, LogAction logAction, SystemName systemName, string logMessage, object logJsonObject, Exception logException)
        {
            var recordLogInfo = new RecordLogInfo
            {
                ADAcnt     = adAccount,
                LogType    = logType.ToString(),
                EventLevel = eventLevel.ToString(),
                SystemName = systemName.ToString(),
                Action     = logAction.ToString(),
                Message    = logMessage,
                Exception  = BuildExceptionMessage(logException)
            };

            try
            {
                try
                {
                    recordLogInfo.Json = JsonConvert.SerializeObject(logJsonObject);
                    return(recordLogInfo);
                }
                catch (Exception)
                {
                    foreach (var item in (IList)logJsonObject)
                    {
                        recordLogInfo.Json += JsonConvert.SerializeObject(item);
                    }
                    return(recordLogInfo);
                }
            }
            catch (Exception e)
            {
                var message = new StringBuilder();
                message.AppendLine();
                message.AppendLine("ConvertLogInfo error, object convert json error!");
                message.AppendLine(BuildExceptionMessage(e));
                NLogWriter(message.ToString(), EventLevel.Error);
                return(recordLogInfo);
            }
        }
        /// <summary>
        /// 將訊息寫入LOG(包含同時寫入NLog與Database log)
        /// </summary>
        /// <param name="adAccount">目前使用者帳號</param>
        /// <param name="logType">Log的類別</param>
        /// <param name="eventLevel">Log等級</param>
        /// <param name="logAction">Log動作</param>
        /// <param name="logMessage">Log訊息</param>
        /// <param name="logJsonObject">如有操作物件,直接將物件填入,會自動產生對應的Json</param>
        /// <param name="logException">如有Exception物件可直接填入,會自動正規化</param>
        public void LogInfoWriter(string adAccount, LogType logType, EventLevel eventLevel, LogAction logAction, SystemName systemName, string logMessage, object logJsonObject, Exception logException)
        {
            //將LogInfo物件轉為RecordLogInfo物件
            var recordLogInfo = ConvertLogInfo(adAccount, logType, eventLevel, logAction, systemName, logMessage, logJsonObject, logException);

            try
            {
                var st = new StackTrace(true);
                //取得呼叫當前方法上一層(GetFrame(1))類別的屬性
                var methodInfo = st.GetFrame(1).GetMethod();
                //無法追朔呼叫當前方法的父類別
                if (methodInfo.DeclaringType == null)
                {
                    NLogWriter("StackTrace is null", EventLevel.Fatal);
                    NLogWriter(JsonConvert.SerializeObject(recordLogInfo), EventLevel.Fatal);
                    return;
                }
                //取得呼叫當前方法的父類別Full class name
                recordLogInfo.LogSystem = methodInfo.DeclaringType.FullName;
                //取得呼叫當前方法的父類別Function name
                recordLogInfo.LogLocation = methodInfo.Name;
                //寫入NLog
                NLogWriter(recordLogInfo);
            }
            catch (Exception e)
            {
                NLogWriter(BuildExceptionMessage(e), EventLevel.Fatal);
                NLogWriter(JsonConvert.SerializeObject(recordLogInfo), EventLevel.Fatal);
            }
        }
 public ActorRequest SetSystem(SystemName sys) =>
     new ActorRequest(Message, To.SetSystem(sys), ReplyTo.SetSystem(sys), RequestId);
 public static SessionAction Start(SessionId sessionId, int timeoutSeconds, SystemName systemName, ProcessName nodeName) =>
     new SessionAction(SessionActionTag.Start, 0L, sessionId, systemName.Value, nodeName.Value, timeoutSeconds, null, null, null);
 public static Unit SetSystem(SystemName system)
 {
     context = system;
     return unit;
 }
 public TerminatedMessage SetSystem(SystemName sys) =>
     new TerminatedMessage(Id.SetSystem(sys));
 public SessionSync(SystemName system, ProcessName nodeName, VectorConflictStrategy strategy)
 {
     this.system   = system;
     this.nodeName = nodeName;
     this.strategy = strategy;
 }
Beispiel #28
0
 public void Have_the_values_not_valid(string sn)
 {
     Check.That(SystemName.IsValid(sn)).IsFalse();
 }
 public static SessionAction SetData(long time, SessionId sessionId, string key, string data, SystemName systemName, ProcessName nodeName) =>
     new SessionAction(SessionActionTag.SetData, time, sessionId, systemName.Value, nodeName.Value, 0, key, data, data.GetType().AssemblyQualifiedName);
Beispiel #30
0
        public override string ToString()
        {
            SystemName systemName = System;

            return(string.Format("MP frontend server '{0}' at system '{1}' (IP address: '{2}')", MPFrontendServerUUID, systemName.HostName, systemName.Address));
        }
 /// <summary>
 /// Finds all *persistent* processes based on the search pattern provided.  Note the returned
 /// ProcessIds may contain processes that aren't currently active.  You can still post
 /// to them however.
 /// </summary>
 /// <param name="keyQuery">Key query.  * is a wildcard</param>
 /// <returns>Matching ProcessIds</returns>
 public static IEnumerable<ProcessId> queryProcesses(string keyQuery, SystemName system = default(SystemName)) =>
     ActorContext.System(system).Cluster
                 .Map(c => c.QueryProcesses(keyQuery))
                 .IfNone(new ProcessId[0]);
 public SessionSync(SystemName system, ProcessName nodeName, VectorConflictStrategy strategy)
 {
     this.system = system;
     this.nodeName = nodeName;
     this.strategy = strategy;
 }
Beispiel #33
0
 /// <summary>
 /// Errors process
 /// Subscribe to it to monitor the errors thrown 
 /// </summary>
 public static ProcessId Errors(SystemName system = default(SystemName)) =>
     ActorContext.System(system).Errors;
Beispiel #34
0
 public static SessionAction Stop(SessionId sessionId, SystemName systemName, ProcessName nodeName) =>
 new SessionAction(SessionActionTag.Stop, 0L, sessionId, systemName.Value, nodeName.Value, 0, null, null, null);
Beispiel #35
0
 /// <summary>
 /// Get a list of cluster nodes that are online
 /// </summary>
 public static Map<ProcessName, ClusterNode> ClusterNodes(SystemName system = default(SystemName)) =>
     ActorContext.System(system).ClusterState == null
         ? Map.empty<ProcessName, ClusterNode>()
         : ActorContext.System(system).ClusterState.Members;
Beispiel #36
0
 public static SessionAction Start(SessionId sessionId, int timeoutSeconds, SystemName systemName, ProcessName nodeName) =>
 new SessionAction(SessionActionTag.Start, 0L, sessionId, systemName.Value, nodeName.Value, timeoutSeconds, null, null, null);
        protected static XmlSerializer _xmlSerializer = null; // Lazy initialized

        public MPClientMetadata(string systemId, SystemName lastHostName, string lastClientName)
        {
            _systemId       = systemId;
            _lastSystem     = lastHostName;
            _lastClientName = lastClientName;
        }
Beispiel #38
0
 public static SessionAction ClearData(long time, SessionId sessionId, string key, SystemName systemName, ProcessName nodeName) =>
 new SessionAction(SessionActionTag.ClearData, time, sessionId, systemName.Value, nodeName.Value, 0, key, null, null);
        public static IDbCommand UpdateAttachedClientDataCommand(ITransaction transaction, string systemId, SystemName system,
                                                                 string clientName)
        {
            IDbCommand result = transaction.CreateCommand();

            result.CommandText = "UPDATE ATTACHED_CLIENTS SET LAST_HOSTNAME = @LAST_HOSTNAME, LAST_CLIENT_NAME = @LAST_CLIENT_NAME WHERE SYSTEM_ID = @SYSTEM_ID";
            ISQLDatabase database = transaction.Database;

            database.AddParameter(result, "LAST_HOSTNAME", system == null ? null : system.HostName, typeof(string));
            database.AddParameter(result, "LAST_CLIENT_NAME", clientName, typeof(string));
            database.AddParameter(result, "SYSTEM_ID", systemId, typeof(string));
            return(result);
        }
Beispiel #40
0
 public static SessionAction SetData(long time, SessionId sessionId, string key, string data, SystemName systemName, ProcessName nodeName) =>
 new SessionAction(SessionActionTag.SetData, time, sessionId, systemName.Value, nodeName.Value, 0, key, data, data.GetType().AssemblyQualifiedName);
Beispiel #41
0
        protected void TryConnect(RootDescriptor rootDescriptor)
        {
            DeviceConnection connection;
            string           deviceUuid;

            lock (_networkTracker.SharedControlPointData.SyncObj)
            {
                if (_connection != null)
                {
                    return;
                }
                DeviceDescriptor rootDeviceDescriptor    = DeviceDescriptor.CreateRootDeviceDescriptor(rootDescriptor);
                DeviceDescriptor backendServerDescriptor = rootDeviceDescriptor.FindFirstDevice(
                    UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE_VERSION);
                if (backendServerDescriptor == null)
                {
                    return;
                }
                deviceUuid = backendServerDescriptor.DeviceUUID;
                string     friendlyName = backendServerDescriptor.FriendlyName;
                SystemName system       = new SystemName(new Uri(rootDescriptor.SSDPRootEntry.PreferredLink.DescriptionLocation).Host);
                if (deviceUuid == _homeServerSystemId)
                {
                    ServiceRegistration.Get <ILogger>().Debug("UPnPClientControlPoint: Found MP2 home server '{0}' (system ID '{1}') at host '{2}' (IP address: '{3}')",
                                                              friendlyName, deviceUuid, system.HostName, system.Address);
                }
                else
                {
                    ServiceRegistration.Get <ILogger>().Debug("UPnPClientControlPoint: Found foreign MP2 server '{0}' (system ID '{1}') at host '{2}' (IP address: '{3}')",
                                                              friendlyName, deviceUuid, system.HostName, system.Address);
                    return;
                }
                try
                {
                    connection = _connection = _controlPoint.Connect(rootDescriptor, deviceUuid, UPnPExtendedDataTypes.ResolveDataType);
                }
                catch (Exception e)
                {
                    ServiceRegistration.Get <ILogger>().Warn("UPnPClientControlPoint: Error connecting to UPnP MP2 backend server '{0}'", e, deviceUuid);
                    return;
                }
            }
            connection.DeviceDisconnected += OnUPnPDeviceDisconnected;
            try
            {
                CpService cdsStub = connection.Device.FindServiceByServiceId(UPnPTypesAndIds.CONTENT_DIRECTORY_SERVICE_ID);
                if (cdsStub == null)
                {
                    throw new InvalidDataException("ContentDirectory service not found in device '{0}' of type '{1}:{2}'",
                                                   deviceUuid, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE_VERSION);
                }
                CpService risStub = connection.Device.FindServiceByServiceId(UPnPTypesAndIds.RESOURCE_INFORMATION_SERVICE_ID);
                if (risStub == null)
                {
                    throw new InvalidDataException("ResourceAccess service not found in device '{0}' of type '{1}:{2}'",
                                                   deviceUuid, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE_VERSION);
                }
                CpService scsStub = connection.Device.FindServiceByServiceId(UPnPTypesAndIds.SERVER_CONTROLLER_SERVICE_ID);
                if (scsStub == null)
                {
                    throw new InvalidDataException("ServerController service not found in device '{0}' of type '{1}:{2}'",
                                                   deviceUuid, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE_VERSION);
                }
                CpService updmStub = connection.Device.FindServiceByServiceId(UPnPTypesAndIds.USER_PROFILE_DATA_MANAGEMENT_SERVICE_ID);
                if (updmStub == null)
                {
                    throw new InvalidDataException("UserProfileDataManagement service not found in device '{0}' of type '{1}:{2}'",
                                                   deviceUuid, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE_VERSION);
                }
                lock (_networkTracker.SharedControlPointData.SyncObj)
                {
                    _contentDirectoryService          = new UPnPContentDirectoryServiceProxy(cdsStub);
                    _resourceInformationService       = new UPnPResourceInformationServiceProxy(risStub);
                    _serverControllerService          = new UPnPServerControllerServiceProxy(scsStub);
                    _userProfileDataManagementService = new UPnPUserProfileDataManagementServiceProxy(updmStub);
                }

                ICollection <UPnPServiceProxyBase> additionalServices = new List <UPnPServiceProxyBase>();
                foreach (AdditionalServiceRegisterDlgt additionalServiceRegistration in _additionalServiceRegistrations)
                {
                    try
                    {
                        additionalServices.Add(additionalServiceRegistration(connection));
                    }
                    catch (Exception e)
                    {
                        ServiceRegistration.Get <ILogger>().Warn("UPnPClientControlPoint: Error registering user service for UPnP MP2 backend server '{0}'", e, deviceUuid);
                    }
                }
                lock (_networkTracker.SharedControlPointData.SyncObj)
                    _additionalServices = additionalServices;
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Warn("UPnPClientControlPoint: Error connecting to services of UPnP MP2 backend server '{0}'", e, deviceUuid);
                connection.DeviceDisconnected -= OnUPnPDeviceDisconnected;
                _controlPoint.Disconnect(deviceUuid);
                return;
            }
            InvokeBackendServerDeviceConnected(connection);
        }
 /// <summary>
 /// Determines whether this instance and another specified PluginDescriptor object have the same SystemName
 /// </summary>
 /// <param name="value">The PluginDescriptor to compare to this instance</param>
 /// <returns>True if the SystemName of the value parameter is the same as the SystemName of this instance; otherwise, false</returns>
 public override bool Equals(object value)
 {
     return(SystemName?.Equals((value as PluginDescriptor)?.SystemName) ?? false);
 }
 public ActorResponse SetSystem(SystemName sys) =>
     new ActorResponse(Message, ResponseMessageType, ReplyTo.SetSystem(sys), ReplyFrom.SetSystem(sys), RequestId, IsFaulted);
Beispiel #44
0
 /// <summary>
 /// Determines whether this instance and another specified ModuleInfo object have the same SystemName
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public override bool Equals(object value)
 {
     return(SystemName.Equals((value as ModuleInfo).SystemName));
 }
 public static Unit SetSystem(ActorSystem system)
 {
     context = system.SystemName;
     return unit;
 }
Beispiel #46
0
 public void AddAvailableSystem(SystemName sysName)
 {
     availableSystems.Add(sysName);
 }
Beispiel #47
0
        public static string Derivative(SystemName system, int channel, SignalName sensor)
        {
            const string kParent = "derivative";

            return(string.Format("{0}.{1}.{2}.{3}", kParent, system, channel, sensor).ToLower());
        }
Beispiel #48
0
 public List <FileProperties> GetFileProperties(SystemName systemName)
 {
     return(GetFilePropertiesString(systemName.ToString()));
 }
 public static SessionAction Stop(SessionId sessionId, SystemName systemName, ProcessName nodeName) =>
     new SessionAction(SessionActionTag.Stop, 0L, sessionId, systemName.Value, nodeName.Value, 0, null, null, null);
Beispiel #50
0
        public override bool Equals(object obj)
        {
            var other = obj as PluginDescriptor;

            return(other != null && SystemName != null && SystemName.Equals(other.SystemName));
        }
 public static SessionAction ClearData(long time, SessionId sessionId, string key, SystemName systemName, ProcessName nodeName) =>
     new SessionAction(SessionActionTag.ClearData, time, sessionId, systemName.Value, nodeName.Value, 0, key, null, null);
Beispiel #52
0
 /// <summary>
 /// Root process ID
 /// The Root process is the parent of all processes
 /// </summary>
 public static ProcessId Root(SystemName system = default(SystemName)) =>
     ActorContext.System(system).Root;
 public UserMessage SetSystem(SystemName sys) =>
     new UserMessage(Content, Sender.SetSystem(sys), ReplyTo.SetSystem(sys));
Beispiel #54
0
 /// <summary>
 /// User process ID
 /// The User process is the default entry process, your first process spawned
 /// will be a child of this process.
 /// </summary>
 public static ProcessId User(SystemName system = default(SystemName)) =>
     ActorContext.System(system).User;
 /// <summary>
 /// Finds all *persistent* registered names in a role
 /// </summary>
 /// <param name="role">Role to limit search to</param>
 /// <param name="keyQuery">Key query.  * is a wildcard</param>
 /// <returns>Registered names</returns>
 public static IEnumerable<ProcessName> queryRegistered(ProcessName role, string keyQuery, SystemName system = default(SystemName)) =>
     ActorContext.System(system).Cluster
                 .Map(c => c.QueryRegistered(role.Value, keyQuery))
                 .IfNone(List.empty<ProcessName>());
Beispiel #56
0
 /// <summary>
 /// Dead letters process
 /// Subscribe to it to monitor the failed messages (<see cref="subscribe(ProcessId)"/>)
 /// </summary>
 public static ProcessId DeadLetters(SystemName system = default(SystemName)) =>
     ActorContext.System(system).DeadLetters;
 /// <summary>
 /// Finds all *persistent* processes based on the search pattern provided and then returns the
 /// meta-data associated with them.
 /// </summary>
 /// <param name="keyQuery">Key query.  * is a wildcard</param>
 /// <returns>Map of ProcessId to ProcessMetaData</returns>
 public static Map<ProcessId, ProcessMetaData> queryProcessMetaData(string keyQuery, SystemName system = default(SystemName)) =>
     ActorContext.System(system).Cluster
                 .Map(c => c.QueryProcessMetaData(keyQuery))
                 .IfNone(Map.empty<ProcessId,ProcessMetaData>());
Beispiel #58
0
 public void RemoveAvailableSystem(SystemName sysName)
 {
     availableSystems.Remove(sysName);
 }