public void OnMqttMsgSubscribeReceived(ushort messageId, string[] topics, byte[] qosLevels)
 {
     if (ProcessingManager != null)
     {
         ProcessingManager.OnMqttMsgSubscribeReceived(this, messageId, topics, qosLevels);
     }
 }
 public void OnConnectionClosed()
 {
     if (ProcessingManager != null)
     {
         ProcessingManager.OnConnectionClosed(this);
     }
 }
 public void OnMqttMsgPublishReceived(MqttMsgPublish msg)
 {
     if (ProcessingManager != null)
     {
         ProcessingManager.OnMqttMsgPublishReceived(this, msg);
     }
 }
 public void OnMqttMsgConnected(MqttMsgConnect connect)
 {
     if (ProcessingManager != null)
     {
         ProcessingManager.OnMqttMsgConnected(this, connect);
     }
 }
 public void EnqueueRawMessage(MqttRawMessage rawMessage)
 {
     if (ProcessingManager != null)
     {
         ProcessingManager.EnqueueRawMessageForProcessing(rawMessage);
     }
 }
 public void EnqueueInflightCallback(InflightQueueProcessEvent processEvent)
 {
     if (ProcessingManager != null)
     {
         ProcessingManager.EnqueueClientConnectionWithInflightQueueToProcess(processEvent);
     }
 }
        private ActionResult HandleRequest(Dictionary <string, object> request, string method, IRequestHandler handler)
        {
            var authHeader = HttpContext.Request.Headers["Authorization"];

            if (authHeader.Count == 0)
            {
                return(Unauthorized());
            }

            Logger.LogInfo($"started {method} request", "");

            var response = new ProcessingManager().PRRequest($"purchase/{method}", JsonConvert.SerializeObject(request), authHeader);

            Logger.LogInfo($"finished {method} request", "");


            if (response.IsSuccess)
            {
                HttpContext.Response.Headers.Add("Content-Type", "application/json");
                var responseData    = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.ResponseStr);
                var handledResponse = handler.GetHandledResponse(responseData);
                return(Ok(handledResponse));
            }
            else
            {
                return(BadRequest(response.ResponseStr));
            }
        }
 public void EnqueueInternalEvent(InternalEvent internalEvent)
 {
     if (ProcessingManager != null)
     {
         EventQueue.Enqueue(internalEvent);
         ProcessingManager.EnqueueClientConnectionWithInternalEventQueueToProcess(this);
     }
 }
        public ConfigurationsTestForm(List <ConfigurationBase> configurations)
        {
            InitializeComponent();
            Configurations        = configurations;
            Template              = SynapseMain.GetCurrentTemplate;
            MainProcessingManager = new ProcessingManager(SynapseMain.IsMainDashing, Template, null, null);

            Awake();
        }
示例#10
0
        private ActionResult HandleRequest(Dictionary <string, object> request, string method, IPreRequestHandler preRequestHandler, IRequestHandler afterRequestHandler)
        {
            System.Diagnostics.Stopwatch timerGlobal = new Stopwatch();

            timerGlobal.Start();
            var authHeader = HttpContext.Request.Headers["Authorization"];

            if (authHeader.Count == 0)
            {
                return(Unauthorized());
            }

            Logger.LogInfo($"started preRequest {method}", "");

            Dictionary <string, object> additionalResponseData = null;

            if (preRequestHandler != null)
            {
                var result = preRequestHandler.GetHandledRequest(request);
                request = result.Request;
                additionalResponseData = result.AdditionalResponseData;
            }

            Logger.LogInfo($"finished preRequest {method}", "");

            Logger.LogInfo($"started {method} request", "");
            System.Diagnostics.Stopwatch timer = new Stopwatch();

            timer.Start();

            var response = new ProcessingManager().PRRequest($"purchase/{method}", JsonConvert.SerializeObject(request), authHeader);

            timer.Stop();
            Logger.LogInfo($"finished {method} request: time: {timer.ElapsedMilliseconds}", "");

            if (response.IsSuccess)
            {
                HttpContext.Response.Headers.Add("Content-Type", "application/json");
                var responseData    = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.ResponseStr);
                var handledResponse = afterRequestHandler.GetHandledResponse(request, responseData, additionalResponseData);
                timerGlobal.Stop();
                Logger.LogInfo($"finished {method} Global request: time: {timerGlobal.ElapsedMilliseconds}", "");
                return(Ok(handledResponse));
            }
            else if (response.IsUnathorized)
            {
                timerGlobal.Stop();
                Logger.LogInfo($"finished {method} Global request: time: {timerGlobal.ElapsedMilliseconds}", "");
                return(Unauthorized());
            }
            else
            {
                timerGlobal.Stop();
                Logger.LogInfo($"finished {method} Global request: time: {timerGlobal.ElapsedMilliseconds}", "");
                return(BadRequest(response.ResponseStr));
            }
        }
        static void Main(string[] args)
        {
            ProcessingManager.Initialize();
            var thread = new Thread(MainLoop);

            thread.Start();

            Console.ReadKey();
        }
 public void EnqueueInflight(MqttMsgContext inflightMessageContext)
 {
     if (ProcessingManager != null)
     {
         InflightQueue.Enqueue(inflightMessageContext);
         ProcessingManager.EnqueueClientConnectionWithInflightQueueToProcess(new InflightQueueProcessEvent {
             ClientConnection = this, IsCallback = false
         });
     }
 }
示例#13
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Service()
        {
            InitializeComponent();

            try
            {
                //Instantiate the processing manager
                m_ProcessingManager = new ProcessingManager();
            }
            catch (Exception ex)
            {
                ErrorHandler.LogError(ex);
            }
        }
 static void MainLoop()
 {
     try
     {
         while (true)
         {
             ProcessingManager.Update();
             Thread.Sleep(1);
         }
     }
     catch (Exception e)
     {
         log.Debug(e.ToString());
     }
 }
示例#15
0
        private async Task Run()
        {
            await Task.CompletedTask.ConfigureAwait(false);

            processingManager = ProcessingManager.InitNewManager(settings.WorkersN);
            processingManager.OnLinkProcessed      += ProcessingManager_OnLinkProcessed;
            processingManager.OnAllWorkersFinished += ProcessingManager_OnAllWorkersFinished;

            processingManager.StartProcessing();

            while (processingManager.DoProcessing)
            {
                await Task.Delay(500);
            }
        }
示例#16
0
        /// <summary>
        /// Constructor
        /// </summary>
        public RequisitionService()
        {
            InitializeComponent();

            try
            {
                //Add a handler for unhandled Exceptions
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                //Instantiate the processing manager
                m_ProcessingManager = new ProcessingManager();
            }
            catch (Exception ex)
            {
                ErrorHandler.LogError(ex);
            }
        }
示例#17
0
        public IActionResult Game(GameInfo gi)
        {
            if (gi.Guid == null || gi.Key == null)
            {
                return(Index(null));
            }
            if (!String.IsNullOrWhiteSpace(gi.Secret))
            {
                if (gi.Game == null)
                {
                    var games = GameManager.GetActiveGameByGuid(gi.Guid);
                    if (games != null && games.Count == 1)
                    {
                        gi.Game = games[0];
                    }
                    else
                    {
                        return(View("Index", null));
                    }
                }
                ProcessingManager.CheckSecretForMirror(gi.Game, gi.Key, gi.Secret);

                if (gi.Tasks == null && gi.Game.LastTaskId.HasValue)
                {
                    var lastTask = GameManager.GetTaskById(gi.Game.LastTaskId.Value);
                    if (lastTask != null)
                    {
                        gi.Tasks = new List <GameTask>()
                        {
                            lastTask
                        };
                    }
                }
                return(View("Game", gi));
            }
            else
            {
                return(View("NoAuth", gi));
            }
            return(Index(null));
        }