当前位置: 首页>>代码示例>>C#>>正文


C# FrontendManager.UpdateNetworkStatus方法代码示例

本文整理汇总了C#中Smuxi.Engine.FrontendManager.UpdateNetworkStatus方法的典型用法代码示例。如果您正苦于以下问题:C# FrontendManager.UpdateNetworkStatus方法的具体用法?C# FrontendManager.UpdateNetworkStatus怎么用?C# FrontendManager.UpdateNetworkStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Smuxi.Engine.FrontendManager的用法示例。


在下文中一共展示了FrontendManager.UpdateNetworkStatus方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Reconnect

        public override void Reconnect(FrontendManager fm)
        {
            Trace.Call(fm);

            fm.SetStatus(_("Reconnecting..."));
            try {
                string msg;
                if (_IrcClient != null) {
                    if (_IrcClient.IsConnected) {
                        Session.AddTextToChat(
                            _NetworkChat,
                            String.Format(
                                "-!- " + _("Reconnecting to {0}..."),
                                _IrcClient.Address
                            )
                        );
                        ApplyConfig(Session.UserConfig, _ServerModel);
                        _IrcClient.Reconnect(true);
                        msg = String.Format(_("Connection to {0} established"),
                                            _IrcClient.Address);
                        fm.SetStatus(msg);
                        Session.AddTextToChat(_NetworkChat, "-!- " + msg);
                    } else {
                        Connect(fm);
                    }
                } else {
                    msg =  _("Reconnect Error");
                    fm.SetStatus(msg);
                    Session.AddTextToChat(_NetworkChat, "-!- " + msg);
                }
            } catch (ConnectionException) {
                fm.SetStatus(String.Empty);
                fm.AddTextToChat(_NetworkChat, "-!- " + _("Not connected"));
            }
            fm.UpdateNetworkStatus();
        }
开发者ID:txdv,项目名称:smuxi,代码行数:36,代码来源:IrcProtocolManager.cs

示例2: Disconnect

        public override void Disconnect(FrontendManager fm)
        {
            Trace.Call(fm);

            fm.SetStatus(_("Disconnecting..."));
            if (IsConnected) {
                Session.AddTextToChat(_NetworkChat, "-!- " +
                    String.Format(_("Disconnecting from {0}..."),
                                  _IrcClient.Address));
                // else the Listen() thread would try to connect again
                _Listening = false;
                _IrcClient.Disconnect();
                fm.SetStatus(String.Format(_("Disconnected from {0}"),
                                           _IrcClient.Address));
                Session.AddTextToChat(_NetworkChat, "-!- " +
                    _("Connection closed"));

                // TODO: set someone else as current network manager?
            } else {
                fm.SetStatus(String.Empty);
                fm.AddTextToChat(_NetworkChat, "-!- " + _("Not connected"));
            }

            if (_RunThread != null && _RunThread.IsAlive) {
                try {
                    _RunThread.Abort();
                } catch (Exception ex) {
            #if LOG4NET
                    _Logger.Error("_RunThread.Abort() failed:", ex);
            #endif
                }
            }
            if (_LagWatcherThread != null && _LagWatcherThread.IsAlive) {
                try {
                    _LagWatcherThread.Abort();
                } catch (Exception ex) {
            #if LOG4NET
                    _Logger.Error("_LagWatcherThread.Abort() failed:", ex);
            #endif
                }
            }

            fm.UpdateNetworkStatus();
        }
开发者ID:txdv,项目名称:smuxi,代码行数:44,代码来源:IrcProtocolManager.cs

示例3: Connect

        public void Connect(FrontendManager fm)
        {
            Trace.Call(fm);

            try {
                string msg;
                msg = String.Format(_("Connecting to {0} port {1}..."), _Host, _Port);
                fm.SetStatus(msg);
                Session.AddTextToChat(_NetworkChat, "-!- " + msg);
                // TODO: add SSL support
                _IrcClient.Connect(_Host, _Port);
                fm.UpdateNetworkStatus();
                msg = String.Format(_("Connection to {0} established"), _Host);
                fm.SetStatus(msg);
                Session.AddTextToChat(_NetworkChat, "-!- " + msg);
                Session.AddTextToChat(_NetworkChat, "-!- " + _("Logging in..."));
                string realname = (string) Session.UserConfig["Connection/Realname"];
                if (realname.Trim().Length == 0) {
                    realname = "unset";
                }
                _IrcClient.Login(_Nicknames, realname, 0, _Username, _Password);

                foreach (string command in (string[]) Session.UserConfig["Connection/OnConnectCommands"]) {
                    if (command.Length == 0) {
                        continue;
                    }
                    CommandModel cd = new CommandModel(_FrontendManager, _NetworkChat,
                        (string) Session.UserConfig["Interface/Entry/CommandCharacter"],
                        command);

                    bool handled;
                    handled = Session.Command(cd);
                    if (!handled) {
                        Command(cd);
                    }
                }
                _Listening = true;
            } catch (CouldNotConnectException ex) {
                fm.SetStatus(_("Connection failed!"));
                Session.AddTextToChat(_NetworkChat, "-!- " + _("Connection failed! Reason: ") + ex.Message);
                throw;
            }
        }
开发者ID:txdv,项目名称:smuxi,代码行数:43,代码来源:IrcProtocolManager.cs

示例4: Connect

        public void Connect(FrontendManager fm)
        {
            Trace.Call(fm);

            try {
                MessageBuilder builder;
                if (!String.IsNullOrEmpty(_IrcClient.ProxyHost)) {
                    builder = CreateMessageBuilder();
                    builder.AppendEventPrefix();
                    builder.AppendText(_("Using proxy: {0}:{1}"),
                                       _IrcClient.ProxyHost,
                                       _IrcClient.ProxyPort);
                    Session.AddMessageToChat(Chat, builder.ToMessage());
                }

                string msg;
                msg = String.Format(_("Connecting to {0} port {1}..."), _Host, _Port);
                fm.SetStatus(msg);
                Session.AddTextToChat(_NetworkChat, "-!- " + msg);
                // TODO: add SSL support
                _IrcClient.Connect(_Host, _Port);
                fm.UpdateNetworkStatus();
                msg = String.Format(_("Connection to {0} established"), _Host);
                fm.SetStatus(msg);
                Session.AddTextToChat(_NetworkChat, "-!- " + msg);
                Session.AddTextToChat(_NetworkChat, "-!- " + _("Logging in..."));
                string realname = (string) Session.UserConfig["Connection/Realname"];
                if (realname.Trim().Length == 0) {
                    realname = "unset";
                }
                if (!Regex.IsMatch(_Username, "^[a-z0-9]+$", RegexOptions.IgnoreCase)) {
                    builder = CreateMessageBuilder();
                    builder.AppendEventPrefix();
                    builder.AppendWarningText(
                        "Warning: Your username (ident) contains special " +
                        "characters which the IRC server might refuse. " +
                        "If this happens please change your username in the " +
                        "server settings."
                    );
                    Session.AddMessageToChat(_NetworkChat, builder.ToMessage());
                }
                _IrcClient.Login(_Nicknames, realname, 0, _Username, _Password);

                foreach (string command in (string[]) Session.UserConfig["Connection/OnConnectCommands"]) {
                    if (command.Length == 0) {
                        continue;
                    }
                    CommandModel cd = new CommandModel(_FrontendManager, _NetworkChat,
                        (string) Session.UserConfig["Interface/Entry/CommandCharacter"],
                        command);

                    bool handled;
                    handled = Session.Command(cd);
                    if (!handled) {
                        Command(cd);
                    }
                }
                _Listening = true;
            } catch (CouldNotConnectException ex) {
                fm.SetStatus(_("Connection failed!"));
                Session.AddTextToChat(_NetworkChat, "-!- " + _("Connection failed! Reason: ") + ex.Message);
                throw;
            }
        }
开发者ID:flugsio,项目名称:smuxi,代码行数:64,代码来源:IrcProtocolManager.cs

示例5: Connect


//.........这里部分代码省略.........
                    builder.AppendEventPrefix();
                    builder.AppendText(" ");
                    builder.AppendUrl(authUri.AbsoluteUri);
                    Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage());

                    builder = CreateMessageBuilder();
                    builder.AppendEventPrefix();
                    builder.AppendText(
                        _("Once you have allowed Smuxi to access your " +
                          "Twitter account, Twitter will provide a PIN.")
                    );
                    Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage());

                    builder = CreateMessageBuilder();
                    builder.AppendEventPrefix();
                    builder.AppendText(_("Please type: /pin PIN_FROM_TWITTER"));
                    Session.AddMessageToChat(f_ProtocolChat, builder.ToMessage());
                } else {
                    f_OAuthTokens.AccessToken = access[0];
                    f_OAuthTokens.AccessTokenSecret = access[1];
                }
            } catch (Exception ex) {
            #if LOG4NET
                f_Logger.Error("Connect(): Exception", ex);
            #endif
                fm.SetStatus(_("Connection failed!"));
                Session.AddTextToChat(f_ProtocolChat,
                    "-!- " + _("Connection failed! Reason: ") + ex.Message
                );
                return;
            }

            // twitter is sometimes pretty slow, so fetch this in the background
            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    // FIXME: replace with AutoResetEvent
                    while (!HasTokens) {
                        Thread.Sleep(1000);
                    }

                    var message = _("Fetching user details from Twitter, please wait...");
                    Session.AddTextToChat(f_ProtocolChat, "-!- " + message);

                    UpdateUser();

                    message = _("Finished fetching user details.");
                    Session.AddTextToChat(f_ProtocolChat, "-!- " + message);

                    f_IsConnected = true;
                    fm.UpdateNetworkStatus();
                    msg =_("Successfully connected to Twitter.");
                    fm.SetStatus(msg);
                    Session.AddTextToChat(f_ProtocolChat, "-!- " + msg);
                    f_Listening = true;

                    f_FriendsTimelineChat.PersonCount =
                    f_RepliesChat.PersonCount =
                    f_DirectMessagesChat.PersonCount = (int) f_TwitterUser.NumberOfFriends;
                } catch (Exception ex) {
                    var message = _("Failed to fetch user details from Twitter. Reason: ");
            #if LOG4NET
                    f_Logger.Error("Connect(): " + message, ex);
            #endif
                    Session.AddTextToChat(f_ProtocolChat, "-!- " + message + ex.Message);

                    fm.SetStatus(_("Connection failed!"));
                    Session.AddTextToChat(f_ProtocolChat,
                        "-!- " + _("Connection failed! Reason: ") + ex.Message
                    );
                }
            });
            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    // FIXME: replace with AutoResetEvent
                    // f_TwitterUser needed for proper self detection in the
                    // CreatePerson() method
                    while (!HasTokens || f_TwitterUser == null) {
                        Thread.Sleep(1000);
                    }

                    var message = _("Fetching friends from Twitter, please wait...");
                    Session.AddTextToChat(f_ProtocolChat, "-!- " + message);

                    UpdateFriends();

                    message = _("Finished fetching friends.");
                    Session.AddTextToChat(f_ProtocolChat, "-!- " + message);
                } catch (Exception ex) {
                    var message = _("Failed to fetch friends from Twitter. Reason: ");
            #if LOG4NET
                    f_Logger.Error("Connect(): " + message, ex);
            #endif
                    Session.AddTextToChat(f_ProtocolChat, "-!- " + message + ex.Message);
                }
            });

            OpenFriendsTimelineChat();
            OpenRepliesChat();
            OpenDirectMessagesChat();
        }
开发者ID:tuukka,项目名称:smuxi,代码行数:101,代码来源:TwitterProtocolManager.cs

示例6: Reconnect

        public override void Reconnect(FrontendManager fm)
        {
            Trace.Call(fm);

            fm.SetStatus("Reconnecting...");
            try {
                string msg;
                if (_IrcClient != null) {
                    if (_IrcClient.IsConnected) {
                        Session.AddTextToChat(_NetworkChat, "-!- Reconnecting to " + _IrcClient.Address + "...");
                        _IrcClient.Reconnect(true);
                        msg = "Connection to " + _IrcClient.Address + " established";
                        fm.SetStatus(msg);
                        Session.AddTextToChat(_NetworkChat, "-!- "+msg);
                    } else {
                        Connect(fm);
                    }
                } else {
                    fm.SetStatus("Reconnect Error");
                    Session.AddTextToChat(_NetworkChat, "-!- Reconnect Error");
                }
            } catch (ConnectionException) {
                fm.SetStatus("Not connected!");
                fm.AddTextToChat(_NetworkChat, "-!- Not connected");
            }
            fm.UpdateNetworkStatus();
        }
开发者ID:RoninBG,项目名称:smuxi,代码行数:27,代码来源:IrcProtocolManager.cs


注:本文中的Smuxi.Engine.FrontendManager.UpdateNetworkStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。