Beispiel #1
0
        private void OnMessage(object sender, IrcReceivedEventArgs args)
        {
            DebugHandler.TraceMessage("OnMessage Called.", DebugSource.TASK, DebugType.ENTRY_EXIT);

            IrcClientMessageEventArgs eventArgs = new IrcClientMessageEventArgs()
            {
                Channel = args.Channel,
                User    = args.User,
                Message = args.Message
            };

            DebugHandler.TraceMessage(eventArgs.ToString(), DebugSource.TASK, DebugType.ENTRY_EXIT);

            OnIrcClientMessageEvent?.Invoke(this, eventArgs);
        }
Beispiel #2
0
        private async void OnIrcClientMessageEvent(object sender, IrcClientMessageEventArgs args)
        {
            DebugHandler.TraceMessage("OnIrcClientMessageEvent called.", DebugSource.TASK, DebugType.ENTRY_EXIT);
            DebugHandler.TraceMessage(args.ToString(), DebugSource.TASK, DebugType.PARAMETERS);

            try
            {
                if (SendMessageToWebSocketClient)
                {
                    JsonIrcChatMessage messageToSend = new JsonIrcChatMessage()
                    {
                        channel = args.Channel,
                        user    = args.User,
                        message = args.Message
                    };

                    await WebSocketHandler.SendMessage(messageToSend.ToJson());
                }
            }
            catch (Exception e)
            {
                DebugHandler.TraceMessage(e.ToString(), DebugSource.TASK, DebugType.ERROR);
                if (SendMessageToWebSocketClient)
                {
                    JsonError error = new JsonError()
                    {
                        type         = "irc_status_error",
                        errormessage = "Error on sending irc message to client.",
                        errortype    = "exception",
                        exception    = e.ToString()
                    };


                    await WebSocketHandler.SendMessage(error.ToJson());
                }
            }
        }