Example #1
0
        /// <summary>
        /// Start the message broker.
        /// </summary>
        public void Start()
        {
            RegisterMessageBroker();

            //Each Application has its own Scope hierarchy and the root scope is WebScope.
            //There's a global scope that aims to provide common resource sharing across Applications namely GlobalScope.
            //The GlobalScope is the parent of all WebScopes.
            //Other scopes in between are all instances of Scope. Each scope takes a name.
            //The GlobalScope is named "default".
            //The WebScope is named per Application context name.
            //The Scope is named per path name.
            _globalScope      = new GlobalScope();
            _globalScope.Name = "default";
            ScopeResolver scopeResolver = new ScopeResolver(_globalScope);

            GodLesZ.Library.Amf.Messaging.Api.IClientRegistry clientRegistry = _clientManager;
            ServiceInvoker serviceInvoker = new ServiceInvoker();
            ScopeContext   context        = new ScopeContext("/", clientRegistry, scopeResolver, serviceInvoker, null);
            CoreHandler    handler        = new CoreHandler();

            _globalScope.Context = context;
            _globalScope.Handler = handler;
            _globalScope.Register();

            StartServices();
            StartEndpoints();
        }
Example #2
0
        protected void UpdateLocalCoreItems()
        {
            var sm       = ServiceRegistration.Get <ISettingsManager>();
            var settings = sm.Load <LibRetroSettings>();

            string coresDirectory = settings.GetPlatformSpecificCoresDirectory();

            _localCoreItems.Clear();
            try
            {
                if (Directory.Exists(coresDirectory))
                {
                    foreach (string path in Directory.EnumerateFiles(coresDirectory, "*.dll"))
                    {
                        string   coreName = Path.GetFileName(path);
                        CoreInfo coreInfo = CoreHandler.LoadCoreInfo(coreName, settings.InfoDirectory);
                        if (coreInfo != null)
                        {
                            coreName = coreInfo.DisplayName;
                        }
                        ListItem item = new ListItem(Consts.KEY_NAME, coreName);
                        item.SetLabel(Consts.KEY_PATH, path);
                        item.SelectedProperty.Attach(OnCoreItemSelectionChanged);
                        _localCoreItems.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("EmulatorConfigurationModel: Exception loading cores from '{0}'", ex, coresDirectory);
            }
            _localCoreItems.FireChange();
        }
Example #3
0
        protected void UpdateAsync()
        {
            LibRetroSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <LibRetroSettings>();

            _coresDirectory         = settings.GetPlatformSpecificCoresDirectory();
            _infoDirectory          = settings.InfoDirectory;
            _onlyShowSupportedCores = settings.OnlyShowSupportedCores;
            _coreHandler            = new CoreHandler(_coresDirectory, _infoDirectory);

            if ((DateTime.Now - _lastUpdateTime).TotalMinutes < settings.CoreUpdateIntervalMinutes)
            {
                return;
            }
            _lastUpdateTime = DateTime.Now;

            var  sm       = ServiceRegistration.Get <IScreenManager>();
            Guid?dialogId = null;

            ServiceRegistration.Get <IThreadPool>().Add(() =>
            {
                ProgressLabel = "[Emulators.CoreUpdater.UpdatingCores]";
                dialogId      = sm.ShowDialog(DIALOG_CORE_UPDATE_PROGRESS);
                Update();
            },
                                                        e =>
            {
                if (dialogId.HasValue)
                {
                    sm.CloseDialog(dialogId.Value);
                }
            });
        }
Example #4
0
        internal static Task Status(ICoreHandler handler, Message Message)
        {
            CoreHandler core = handler as CoreHandler;

            core.Respond(Message.ChannelId, core.ToString());
            return(Task.CompletedTask);
        }
Example #5
0
        //public SessionResponseData LogIn(SessionRequestData sessionData)
        public ExtendedSessionResponseData GetLoginInfo(string email = "", string password = "",
                                                        int userId   = 0, string sessionId = "",
                                                        OperationTypeEnum operationType = OperationTypeEnum.New,
                                                        ApplicationType applicationType = ApplicationType.Mobile)
        {
            // no permission validation if configured
            if (AppSettings.Get("MobileApi", "ValidateSession", false) == "false")
            {
                return new ExtendedSessionResponseData {
                           UserID = 105, Session = "aaa"
                }
            }
            ;

            var sessionData = new SessionRequestData
            {
                Email           = email,
                Password        = password,
                UserID          = userId,
                Session         = sessionId,
                OperationType   = operationType,
                ApplicationType = applicationType
            };

            var handler = new CoreHandler();

            try
            {
                var response = handler.LogIn(sessionData);

                Log.Write("Mobile API", String.Format("User {0} logged in to Mobile Application", response.UserID), LogMessageType.Debug);
                return(new ExtendedSessionResponseData {
                    UserID = response.UserID, Session = response.Session
                });
            }
            catch (Exception ex)
            {
                Log.Write("Mobile API", String.Format("Login failed for user email '{0}', ex: {1}", email, ex.Message), LogMessageType.Error);
                return(new ExtendedSessionResponseData
                {
                    HasError = true,
                    ErrorMsg = ex.Message,
                    DisplayError = (ex is MobileApiException) ? (ex as MobileApiException).DisplayMessage : null
                });
            }
        }
    }
Example #6
0
        public void Start()
        {
            this.RegisterMessageBroker();
            this._globalScope      = new FluorineFx.Messaging.GlobalScope();
            this._globalScope.Name = "default";
            ScopeResolver   scopeResolver  = new ScopeResolver(this._globalScope);
            IClientRegistry clientRegistry = this._clientManager;
            ServiceInvoker  serviceInvoker = new ServiceInvoker();
            ScopeContext    context        = new ScopeContext("/", clientRegistry, scopeResolver, serviceInvoker, null);
            CoreHandler     handler        = new CoreHandler();

            this._globalScope.Context = context;
            this._globalScope.Handler = handler;
            this._globalScope.Register();
            this.StartServices();
            this.StartEndpoints();
        }
Example #7
0
 internal Task Broadcast(ICoreHandler handler, string broadcast)
 {
     try {
         CoreHandler core = handler as CoreHandler;
         foreach (DiscordGuild guild in core.Guilds)
         {
             if (guild.SystemChannelId.HasValue)
             {
                 core.Respond(guild.SystemChannelId.Value, broadcast);
             }
             else
             {
                 core.Respond(guild.Id, broadcast);
             }
         }
     } catch (Exception ex) {
         log.Error(ex.ToString());
         throw;
     }
     return(Task.CompletedTask);
 }