コード例 #1
0
        private void OnUserListUpdate(object sender, IrcUserListReceivedEventArgs args)
        {
            DebugHandler.TraceMessage("OnUserListUpdate Called.", DebugSource.TASK, DebugType.ENTRY_EXIT);

            try
            {
                if (args.UsersPerChannel.Count > 0)
                {
                    IrcClientConnectionStatusArgs eventArgs = new IrcClientConnectionStatusArgs()
                    {
                        ChannelsAndUsers   = args.UsersPerChannel,
                        Connected          = true,
                        CurrentIrcSettings = IrcSettings
                    };

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

                    if (!IsConnectedBool)
                    {
                        OnIrcClientConnectionStatusEvent?.Invoke(this, eventArgs);
                    }
                    IsConnectedBool = true;
                }
            }
            catch (Exception e)
            {
                DebugHandler.TraceMessage(e.ToString(), DebugSource.TASK, DebugType.WARNING);
            }
        }
コード例 #2
0
        private async void OnIrcClientConnectionStatusEvent(object sender, IrcClientConnectionStatusArgs args)
        {
            DebugHandler.TraceMessage("OnIrcClientConnectionStatusEvent called.", DebugSource.TASK, DebugType.ENTRY_EXIT);
            DebugHandler.TraceMessage(args.ToString(), DebugSource.TASK, DebugType.PARAMETERS);


            IsIrcConnected = args.Connected;

            try
            {
                JsonIrcInfo update = new JsonIrcInfo()
                {
                    connected    = args.Connected,
                    channel      = args.CurrentIrcSettings.Channels,
                    server       = args.CurrentIrcSettings.ServerAddress,
                    user         = args.CurrentIrcSettings.UserName,
                    fullfilepath = args.CurrentIrcSettings.fullfilepath
                };

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