Exemplo n.º 1
0
        /// <summary>
        /// reading the message from the service and invoke the relevant listeners about this message.
        /// </summary>
        /// <param name="message">the message that received from the service.</param>
        private void ProcessAndSend(string message)
        {
            // Parsing our jobjects command enum
            JObject obj = JObject.Parse(message);

            int.TryParse(obj["CommandEnum"].ToString(), out int command);
            MessageEventArgs m = new MessageEventArgs(message);

            // Sending the server message to the right gui tab via event
            switch (command)
            {
            case (int)Infrastructure.Enums.CommandEnum.GetConfigCommand:
                ConfigRecieved?.Invoke(this, m);
                break;

            case (int)Infrastructure.Enums.CommandEnum.LogCommand:
                LogUdated?.Invoke(this, m);
                break;

            case (int)Infrastructure.Enums.CommandEnum.CloseCommand:
                RemovedHandler?.Invoke(this, m);
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// reading the message from the service and invoke the relevant listeners about this message.
        /// </summary>
        /// <param name="message">the message that received from the service.</param>
        private void ProcessAndSend(string message)
        {
            string[]         commandAndArg = message.Split('#');
            MessageEventArgs m             = new MessageEventArgs(commandAndArg[1]);

            switch (commandAndArg[0])
            {
            case "ConfigRecieved":
                ConfigRecieved?.Invoke(this, m);
                break;

            case "LogUpdated":
                LogUdated?.Invoke(this, m);
                break;

            case "RemovedHandler":
                RemovedHandler?.Invoke(this, m);
                break;

            default:
                break;
            }
        }