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); } }
private static async void OnSetLogConfig(IDevSocket pSocket, IDevMessage pMessage) { if (pMessage is IDevRequest request) { await pSocket.RespondAt(request); _targetOuput.Socket = pSocket; CreateRandomLogs().RunSafe(); } }
private static void IdentificationRequestHandler(IDevSocket pSocket, IDevMessage pMessage) { if (pMessage is IDevRequest request) { pSocket.RespondAt(request, new DevIdentificationResponse { AppName = AppDomain.CurrentDomain.FriendlyName }); } }
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); } }