Ejemplo n.º 1
0
        /// <summary>
        /// Starts the connection to the irc server, sends the register user command and register nick name command.
        /// </summary>
        /// <returns>true/false depending if error coccured</returns>
        public bool Connect()
        {
            try
            {
                _isConnectionEstablised = false;
                _receiverTask           = new Task(StartReceivingChat);
                _receiverTask.Start();

                int timeout = 0;
                while (!_isConnectionEstablised)
                {
                    Thread.Sleep(1);
                    if (timeout > _timeOut)
                    {
                        return(false);
                    }
                    timeout++;
                }

                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("IRC CLIENT SUCCESFULLY RUNNING", "IRC SETUP"));
                return(true);
            }
            catch (Exception e)
            {
                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs(e.ToString(), "SETUP ERROR"));
                return(false);
            }
        }
Ejemplo n.º 2
0
 //
 public void Ini()
 {
     cm = new IniComment();
     cv = new IniConvert();
     ResetDefaultOptions();
     OnDebug += new OnDebugMessage(OnDefaultDebugMessage);
 }
Ejemplo n.º 3
0
 private void writeMessage(string message)
 {
     if (OnDebugMessage != null)
     {
         OnDebugMessage.Invoke(this, message);
     }
 }
 private void Send(string message)
 {
     if (logMessages)
     {
         OnDebugMessage?.Invoke("Send: " + message);
     }
     ws.Send(message);
 }
 /// <summary>
 /// The event handler gets called when a message from the device arrives at the debugger
 /// </summary>
 /// <param name="message"></param>
 /// <param name="text"></param>
 private void OnMessage(IncomingMessage message, string text)
 {
     // only the c_Monitor_Message's are interesting
     if (message.Header.Cmd == c_Monitor_Message)
     {
         // if a event handler is attached deliver the message to him
         OnDebugMessage?.Invoke(text);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// The event handler gets called when a message from the device arrives at the debugger
 /// </summary>
 /// <param name="message"></param>
 /// <param name="text"></param>
 private void OnMessage(object message, string text)
 {
     // only the c_Monitor_Message's are interesting
     if ((uint)_packetCmd.GetValue(_incomingMessageHeader.GetValue(message)) == c_Monitor_Message)
     {
         // if a event handler is attached deliver the message to him
         OnDebugMessage?.Invoke(text);
     }
 }
        // TODO: return Task instead of void
        private void OnWebSocketMessage(string data)
        {
            if (logMessages)
            {
                OnDebugMessage?.Invoke("OnMessage: " + data);
            }
            JSONObject message = new JSONObject(data);

            HandleMessage(message);
        }
 public void InitServer(P2PClient thisServer)
 {
     Server?.Dispose();
     Server  = thisServer;
     crypter = new RSA(Server, 768);
     Server.OnDebugMessage += str => OnDebugMessage?.Invoke(this, str);
     Server.OnMessageSend  += p_OnMessageSend;
     Server.OnConnect      += p_OnConnection;
     Server.OnDisconnect   += (_, u) => OnUserDisconnect?.Invoke(this, u);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Stops a download if a download is running.
 /// </summary>
 /// <returns>true/false depending if an error occured or not</returns>
 public bool StopXDCCDownload()
 {
     try
     {
         return(!_dccClient.AbortDownloader(_timeOut));
     } catch (Exception e)
     {
         OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("Could not stop XDCC Download, error: " + e.ToString(), "IRC CLIENT XDCC STOP"));
         return(true);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Checks if a download is running or not.
 /// </summary>
 /// <returns>true/false depending if a download is running, or if an error occured</returns>
 public bool CheckIfDownloading()
 {
     try
     {
         return(_dccClient.CheckIfDownloading());
     }
     catch (Exception e)
     {
         OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("Could not check if download has started, error: " + e.ToString(), "IRC CLIENT XDCC CHECK"));
         return(false);
     }
 }
        protected void DebugLog(string msg)
        {
            switch (DebugMode)
            {
            case DEBUG_MODE.UNITY_DEBUG_LOG:
                Debug.Log(msg);
                break;

            case DEBUG_MODE.EVENT:
                OnDebugMessage?.Invoke(msg);
                break;
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Writes a message to the irc server.
 /// </summary>
 /// <param name="input">Message to send</param>
 /// <returns>true/false depending if it could write to the irc server</returns>
 public bool WriteIrc(string input)
 {
     try
     {
         _streamWriter.Write(input + Environment.NewLine);
         _streamWriter.Flush();
         return(true);
     } catch (Exception e)
     {
         OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("Could not send message" + input + ", _tcpClient client is not running :X, error : " + e.ToString(), "MESSAGE SENDER"));;
         return(false);
     }
 }
 public void OnWebSocketOpen()
 {
     OnDebugMessage?.Invoke("Websocket open");
     Send(GetConnectMessage());
     foreach (Subscription subscription in subscriptions.Values)
     {
         Send(GetSubscriptionMessage(subscription));
     }
     foreach (MethodCall methodCall in methodCalls.Values)
     {
         Send(GetMethodCallMessage(methodCall));
     }
 }
 public async Task ConnectAsync()
 {
     if ((ddpConnectionState == ConnectionState.NOT_CONNECTED) ||
         (ddpConnectionState == ConnectionState.DISCONNECTED) ||
         (ddpConnectionState == ConnectionState.CLOSED))
     {
         ddpConnectionState = ConnectionState.CONNECTING;
         if (logMessages)
         {
             OnDebugMessage?.Invoke("Connecting to " + url + " ...");
         }
         await ws.ConnectAsync();
     }
     else if (logMessages)
     {
         OnDebugMessage?.Invoke("Connect request ignored: Already " + ddpConnectionState);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Inspects the log level of the event data and triggers the corresponding event if there is a listener.
        /// </summary>
        /// <param name="e">The <see cref="LogEventArgs"/> instance containing the event data.</param>
        internal static void RaiseException(LogEventArgs e)
        {
            if (MuteMessages)
            {
                return;
            }

            if (e != null)
            {
                switch (e.LogLevel)
                {
                case LogLevelType.Verbose:
                    OnVerboseMessage?.Invoke(e);

                    break;

                case LogLevelType.Debug:
                    OnDebugMessage?.Invoke(e);

                    break;

                case LogLevelType.Info:
                    OnInfoMessage?.Invoke(e);

                    break;

                case LogLevelType.Warn:
                    OnWarnMessage?.Invoke(e);

                    break;

                case LogLevelType.Error:
                    OnErrorMessage?.Invoke(e);

                    break;

                case LogLevelType.Fatal:
                    OnFatalMessage?.Invoke(e);

                    break;
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Starts quiting procedure, sends QUIT message to server and waits until server closes connection with the client, after that, it shuts down every reader and stream, and stops the receiver task.
        /// </summary>
        /// <returns></returns>
        public bool QuitConnect()
        {
            OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("STARTING IRC CLIENT SHUTDOWN PROCEDURE", "QUIT"));
            //send quit to server
            if (WriteIrc("QUIT"))
            {
                int timeout = 0;
                while (_tcpClient.Connected)
                {
                    Thread.Sleep(1);
                    if (timeout >= _timeOut)
                    {
                        return(false);
                    }
                    timeout++;
                }

                _stopTask = true;
                Thread.Sleep(200);
                //stop everything in right order
                _receiverTask.Dispose();
                _streamReader.Dispose();
                if (_networkStream != null)
                {
                    _networkStream.Close();
                }
                _streamWriter.Close();
                _tcpClient.Close();

                _isConnectionEstablised = false;

                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("FINISHED SHUTDOWN PROCEDURE", "QUIT"));
                return(true);
            }
            else
            {
                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("COULD NOT WRITE QUIT COMMAND TO SERVER", "QUIT"));
                return(true);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Sets up the information needed for the client to start a connection to the irc server. Sends a warning to the debug message event if ports are out of the standard specified ports for IRC.
        /// </summary>
        /// <param name="ip">Server address, possibly works with dns addresses (irc.xxx.x), but ip addresses works just fine (of type string)</param>
        /// <param name="username">Username the client wants to use, of type string</param>
        /// <param name="channels">Channel(s) the client wants to connect to, possible to connect to multiple channels at once by seperating each channel with a ',' (Example: #chan1,#chan2), of type string</param>
        /// <param name="dccClient">DCC Client, for downloading using the DCC protocol</param>
        /// <param name="downloadDirectory">Download Directory, used by the DCC CLient to store files in the specified directory, if left empty, it will create a "Download" directory within the same folder where this library resides</param>
        /// <param name="port">Port, optional parameter, where default = 0 (Automatic port selection), is port of the server you want to connect to, of type int</param>
        /// <param name="password">Password, optional parameter, where default value is "", can be used to connect to a password protected server.</param>
        /// <param name="timeout">Timeout, optional parameter, where default value is 3000 milliseconds, the maximum time before a server needs to answer, otherwise errors are thrown.</param>
        /// <param name="enableSSL">Timeout, optional parameter, where default value is 3000 milliseconds, the maximum time before a server needs to answer, otherwise errors are thrown.</param>
        public void SetConnectionInformation(string ip, string username, string channels,
                                             DCCClient dccClient, string downloadDirectory, int port = 0, string password = null, int timeout = 3000, bool enableSSL = true, bool ignoreSelfSignedCertificate = false)
        {
            this._newIp                  = ip;
            this._NewPort                = port;
            this._NewUsername            = username;
            this._newPassword            = password;
            this._NewChannelss           = channels;
            this._isConnectionEstablised = false;
            this._IsClientRunning        = false;
            this._timeOut                = timeout;
            this._downloadDirectory      = downloadDirectory;
            this._dccClient              = dccClient;
            this._enableSSL              = enableSSL;
            this._acceptAllCertificates  = ignoreSelfSignedCertificate;

            if (_enableSSL)
            {
                if (port == 0)
                {
                    _NewPort = 6697;
                }
                else if (port != 6697)
                {
                    OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("PORT: " + port.ToString() + " IS NOT COMMONLY USED FOR TLS/SSL CONNECTIONS, PREFER TO USE 6697 FOR SSL!", "SETUP WARNING"));
                }
            }
            else
            {
                if (port == 0)
                {
                    _NewPort = 6667;
                }
                else if (port < 6665 && port > 6669)
                {
                    OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("PORT: " + port.ToString() + " IS NOT COMMONLY USED FOR NON TLS/SSL CONNECTIONS, PREFER TO USE PORTS BETWEEN 6665 & 6669!", "SETUP WARNING"));
                }
            }
        }
Ejemplo n.º 18
0
 public void SendDebugMessage(string messageToWrite, LogLevel logLevel = LogLevel.Debug)
 {
     OnDebugMessage?.Invoke(this, messageToWrite, logLevel);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Stops the client.
 /// </summary>
 public bool StopClient()
 {
     _stopTask = true;
     OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("CLOSING CLIENT", "CLOSE"));
     return(QuitConnect());
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Starts the receiver task.
        /// </summary>
        public void StartReceivingChat()
        {
            _tcpClient = new TcpClient(_newIp, _NewPort);

            int timeout = 0;

            while (!_tcpClient.Connected)
            {
                Thread.Sleep(1);

                if (timeout >= _timeOut)
                {
                    OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("TIMEOUT, COULD NOT CONNECT TO TCP SOCKET", "IRC SETUP"));
                }
                timeout++;
            }


            try
            {
                if (!_enableSSL)
                {
                    _networkStream = _tcpClient.GetStream(); Thread.Sleep(500);
                    _streamReader  = new StreamReader(_networkStream);
                    _streamWriter  = new StreamWriter(_networkStream);
                    _ircCommands   = new IrcCommands(_networkStream);
                }
                else
                {
                    _networkSStream = new SslStream(_tcpClient.GetStream());
                    _networkSStream.AuthenticateAsClient(_newIp);
                    _streamReader = new StreamReader(_networkSStream);
                    _streamWriter = new StreamWriter(_networkSStream);
                    _ircCommands  = new IrcCommands(_networkSStream);
                }



                _isConnectionEstablised = true;
                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("CONNECTED TO TCP SOCKET", "IRC SETUP"));



                if (_newPassword.Length > 0)
                {
                    if (!_ircCommands.SetPassWord(_newPassword))
                    {
                        OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs(_ircCommands.GetErrorMessage(), "IRC SETUP ERROR"));
                        _isConnectionEstablised = false;
                    }
                }
                Debug.WriteLine("Joining channels: " + _NewChannelss);
                if (!_ircCommands.JoinNetwork(_NewUsername, _NewChannelss))
                {
                    OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs(_ircCommands.GetErrorMessage(), "IRC SETUP ERROR"));
                    _isConnectionEstablised = false;
                }
            }
            catch (Exception ex)
            {
                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs(ex.ToString(), "IRC SETUP"));
            }



            if (_isConnectionEstablised)
            {
                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("CONNECTED TO IRC SERVER", "IRC SETUP"));
                _stopTask = false;
                Task.Run(() => ReceiveChat());
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Changes the download directory, will apply to the next instantiated download.
 /// </summary>
 /// <param name="downloadDirectory">Path to directory (creates it if it does not exist)</param>
 public void SetDownloadDirectory(string downloadDirectory)
 {
     OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("SET DOWNLOAD DIRECTORY: " + downloadDirectory, "SETTING DOWNLOAD DIRECTORY"));
     _downloadDirectory = downloadDirectory;
 }
Ejemplo n.º 22
0
        private void OnDebugMessageChanged(string v)
        {
            // Something TODO ?

            OnDebugMessage?.Invoke(this, new PropertyChangedEventArgs(v));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Receiver task, receives messages from server, handles joining intial join to channels, if the server responses with a 004 (which is a welcome message, meaning it has succesfully connected)
        /// Handles PRIVMSG messages
        /// Handles PING messages
        /// Handles JOIN messages
        /// Handles QUIT messages (though it's not yet possible to determine which channels these users have left
        /// Handles 353 messages (Users list per channel)
        /// Handles 366 messages (Finished user list per channel)
        /// Handles DCC SEND messages
        /// </summary>
        private void ReceiveChat()
        {
            try
            {
                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("STARTING LISTENER!", "IRC RECEIVER"));


                Dictionary <string, List <string> > usersPerChannelDictionary = new Dictionary <string, List <string> >();

                _IsClientRunning        = true;
                _isConnectionEstablised = true;
                while (!_stopTask)
                {
                    string ircData = _streamReader.ReadLine();

                    OnRawMessageReceived?.Invoke(this, new IrcRawReceivedEventArgs(ircData));



                    if (ircData.Contains("PING"))
                    {
                        string pingID = ircData.Split(':')[1];
                        WriteIrc("PONG :" + pingID);
                    }
                    if (ircData.Contains("PRIVMSG"))
                    {
                        //:[email protected] PRIVMSG #RareIRC :wassup



                        try
                        {
                            string messageAndChannel = ircData.Split(new string[] { "PRIVMSG" }, StringSplitOptions.None)[1];
                            string message           = messageAndChannel.Split(':')[1].Trim();
                            string channel           = messageAndChannel.Split(':')[0].Trim();
                            string user = ircData.Split(new string[] { "PRIVMSG" }, StringSplitOptions.None)[0].Split('!')[0].Substring(1);

                            channel = channel.Replace("=", string.Empty);

                            OnMessageReceived?.Invoke(this, new IrcReceivedEventArgs(message, user, channel));
                        }
                        catch (Exception ex)
                        {
                            OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs(ex.ToString(), "MESSAGE RECEIVED ERROR (PRIVMSG)"));
                        }
                    }
                    else if (ircData.Contains("JOIN"))
                    {
                        //RAW: :[email protected] JOIN :#NIBL


                        try
                        {
                            string channel        = ircData.Split(new string[] { "JOIN" }, StringSplitOptions.None)[1].Split(':')[1];
                            string userThatJoined = ircData.Split(new string[] { "JOIN" }, StringSplitOptions.None)[0].Split(':')[1].Split('!')[0];

                            OnMessageReceived?.Invoke(this, new IrcReceivedEventArgs("User Joined", userThatJoined, channel));
                        }
                        catch (Exception ex)
                        {
                            OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs(ex.ToString(), "MESSAGE RECEIVED ERROR (JOIN)"));
                        }
                    }
                    else if (ircData.Contains("QUIT"))
                    {
                        //RAW: :[email protected] QUIT
                        try
                        {
                            string user = ircData.Split(new string[] { "QUIT" }, StringSplitOptions.None)[0].Split('!')[0].Substring(1);

                            OnMessageReceived?.Invoke(this, new IrcReceivedEventArgs("User Left", user, "unknown"));
                        }
                        catch (Exception ex)
                        {
                            OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs(ex.ToString(), "MESSAGE RECEIVED ERROR (JOIN)"));
                        };
                    }

                    if (ircData.Contains("DCC SEND") && ircData.Contains(_NewUsername))
                    {
                        _dccClient.StartDownloader(ircData, _downloadDirectory, _bot, _packNumber, this);
                    }

                    //RareIRC_Client = #weebirc :RareIRC_Client
                    if (ircData.Contains(" 353 "))
                    {
                        //:irc.x2x.cc 353 RoflHerp = #RareIRC :RoflHerp @MrRareie
                        try
                        {
                            string channel            = ircData.Split(new[] { " " + _NewUsername + " =" }, StringSplitOptions.None)[1].Split(':')[0].Replace(" ", string.Empty);
                            string userListFullString = ircData.Split(new[] { " " + _NewUsername + " =" }, StringSplitOptions.None)[1].Split(':')[1];


                            if (!channel.Contains(_NewUsername) && !channel.Contains("="))
                            {
                                string[] users = userListFullString.Split(' ');
                                if (usersPerChannelDictionary.ContainsKey(channel))
                                {
                                    usersPerChannelDictionary.TryGetValue(channel, out var currentUsers);


                                    foreach (string name in users)
                                    {
                                        if (!name.Contains(_NewUsername))
                                        {
                                            currentUsers.Add(name);
                                        }
                                    }
                                    usersPerChannelDictionary[channel.Trim()] = currentUsers;
                                }
                                else
                                {
                                    List <string> currentUsers = new List <string>();
                                    foreach (string name in users)
                                    {
                                        currentUsers.Add(name);
                                    }
                                    usersPerChannelDictionary.Add(channel.Trim(), currentUsers);
                                }
                            }
                        } catch (Exception ex)
                        {
                            OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs(ex.ToString(), "MESSAGE RECEIVED ERROR (USERLIST)"));
                        }
                    }

                    if (ircData.ToLower().Contains(" 366 "))
                    {
                        OnUserListReceived?.Invoke(this, new IrcUserListReceivedEventArgs(usersPerChannelDictionary));
                        usersPerChannelDictionary.Clear();
                    }
                    Thread.Sleep(1);
                }

                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("RECEIVER HAS STOPPED RUNNING", "MESSAGE RECEIVER"));

                QuitConnect();
                _stopTask = false;
            } catch (Exception ioex)
            {
                OnDebugMessage?.Invoke(this, new IrcDebugMessageEventArgs("LOST CONNECTION: " + ioex.ToString(), "MESSAGE RECEIVER"));
                if (_isConnectionEstablised)
                {
                    _stopTask = false;
                    QuitConnect();
                }
            }
            _IsClientRunning = false;
        }
Ejemplo n.º 24
0
        private void v_ReceivedMessage(object peer)
        {
            NetIncomingMessage msg = Server.ReadMessage();

            switch (msg.MessageType)
            {
            case NetIncomingMessageType.Error:
                OnError?.Invoke(msg.ReadString());

                break;



            case NetIncomingMessageType.StatusChanged:
                OnClientStatusChanged?.Invoke(msg.SenderConnection, msg.SenderConnection.Status);

                if (msg.SenderConnection.Status == NetConnectionStatus.Connected)
                {
                    OnClientConnected?.Invoke(msg.SenderConnection);
                }

                break;


            case NetIncomingMessageType.ConnectionApproval:
                v_HandleConnectionAuth(msg);

                break;


            case NetIncomingMessageType.Data:
                v_HandlePacket(msg);

                break;


            case NetIncomingMessageType.DiscoveryRequest:
                if (!DiscoveryResponse(msg, Server, out NetOutgoingMessage resp))
                {
                    break;
                }

                Server.SendDiscoveryResponse(resp, msg.SenderEndPoint);

                break;


            case NetIncomingMessageType.VerboseDebugMessage:
            case NetIncomingMessageType.DebugMessage:
                OnDebugMessage?.Invoke(msg.ReadString());

                break;


            case NetIncomingMessageType.WarningMessage:
                OnWarningMessage?.Invoke(msg.ReadString());

                break;


            case NetIncomingMessageType.ErrorMessage:
                OnErrorMessage?.Invoke(msg.ReadString());

                break;
            }
            Server.Recycle(msg);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Clears the listeners that may be attached to the events. Typically used for testing.
        /// </summary>
        public static void ClearListeners()
        {
            try
            {
                if (OnDebugMessage != null)
                {
                    foreach (Delegate invoker in OnDebugMessage.GetInvocationList())
                    {
                        OnDebugMessage -= (LogEventHandler)invoker;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            try
            {
                if (OnErrorMessage != null)
                {
                    foreach (Delegate invoker in OnErrorMessage.GetInvocationList())
                    {
                        OnErrorMessage -= (LogEventHandler)invoker;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            try
            {
                if (OnFatalMessage != null)
                {
                    foreach (Delegate invoker in OnFatalMessage.GetInvocationList())
                    {
                        OnFatalMessage -= (LogEventHandler)invoker;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            try
            {
                if (OnInfoMessage != null)
                {
                    foreach (Delegate invoker in OnInfoMessage.GetInvocationList())
                    {
                        OnInfoMessage -= (LogEventHandler)invoker;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            try
            {
                if (OnVerboseMessage != null)
                {
                    foreach (Delegate invoker in OnVerboseMessage.GetInvocationList())
                    {
                        OnVerboseMessage -= (LogEventHandler)invoker;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            try
            {
                if (OnWarnMessage != null)
                {
                    foreach (Delegate invoker in OnWarnMessage.GetInvocationList())
                    {
                        OnWarnMessage -= (LogEventHandler)invoker;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }