Пример #1
0
        protected void DispatchMessage(IDevSocket pSocket, IDevMessage pMessage)
        {
            if (pMessage == null)
            {
                return;
            }

            bool hasListener = false;

            GetListeners(pMessage?.GetType()).ForEach((l) =>
            {
                try
                {
                    hasListener = true;
                    l?.HandleMessage(pSocket, pMessage);
                }
                catch (Exception e)
                {
                    LOGGER.Error(e, "Une erreur s'est produit pendant la gestion des messages");
                }
            });

            if (!hasListener && pMessage is IDevRequest request)
            {
                // Message non interprété
                pSocket.RespondAt(request, null, false);
            }
        }
Пример #2
0
        private static async void OnSetLogConfig(IDevSocket pSocket, IDevMessage pMessage)
        {
            if (pMessage is IDevRequest request)
            {
                await pSocket.RespondAt(request);

                _targetOuput.Socket = pSocket;
                CreateRandomLogs().RunSafe();
            }
        }
Пример #3
0
 private static void IdentificationRequestHandler(IDevSocket pSocket, IDevMessage pMessage)
 {
     if (pMessage is IDevRequest request)
     {
         pSocket.RespondAt(request, new DevIdentificationResponse
         {
             AppName = AppDomain.CurrentDomain.FriendlyName
         });
     }
 }
Пример #4
0
 private void OnLogReceived(IDevSocket pSocket, IDevMessage pMessage)
 {
     if (pMessage is DevLogsRequest request)
     {
         LOGGER.Debug("Réception de logs");
         if (request.Logs != null)
         {
             Logs.AddRange(request.Logs);
         }
         pSocket.RespondAt(request);
     }
 }