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


C# FrontendManager.AddTextToChat方法代码示例

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


在下文中一共展示了FrontendManager.AddTextToChat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: RegisterFrontendUI

        public void RegisterFrontendUI(IFrontendUI ui)
        {
            Trace.Call(ui);

            if (ui == null) {
                throw new ArgumentNullException("ui");
            }

            string uri = GetUri(ui);
            #if LOG4NET
            f_Logger.Debug("Registering UI with URI: " + uri);
            #endif
            // add the FrontendManager to the hashtable with an unique .NET remoting identifier
            FrontendManager fm = new FrontendManager(this, ui);
            _FrontendManagers[uri] = fm;

            // if this is the first frontend, we process OnStartupCommands
            if (!_OnStartupCommandsProcessed) {
                _OnStartupCommandsProcessed = true;

                MessageModel msg;
                msg = new MessageModel();
                msg.MessageParts.Add(
                    new TextMessagePartModel(new TextColor(0xFF0000), null, false,
                            true, false, _("Welcome to Smuxi")));
                AddMessageToChat(_SessionChat, msg);

                msg = new MessageModel();
                msg.MessageParts.Add(
                    new TextMessagePartModel(null, null, false,
                            true, false, _("Type /help to get a list of available commands.")));
                AddMessageToChat(_SessionChat, msg);

                msg = new MessageModel();
                msg.MessageParts.Add(
                    new TextMessagePartModel(null, null, false,
                            true, false, _("After you have made a connection the list of available commands changes, just use /help again.")));
                AddMessageToChat(_SessionChat, msg);

                foreach (string command in (string[])_UserConfig["OnStartupCommands"]) {
                    if (command.Length == 0) {
                        continue;
                    }
                    CommandModel cd = new CommandModel(fm, _SessionChat,
                        (string)_UserConfig["Interface/Entry/CommandCharacter"],
                        command);
                    bool handled;
                    handled = Command(cd);
                    if (!handled) {
                        if (fm.CurrentProtocolManager != null) {
                            fm.CurrentProtocolManager.Command(cd);
                        }
                    }
                }

                // process server specific connects/commands
                ServerListController serverCon = new ServerListController(_UserConfig);
                IList<ServerModel> servers = serverCon.GetServerList();
                foreach (ServerModel server in servers) {
                    if (!server.OnStartupConnect) {
                        continue;
                    }

                    IProtocolManager protocolManager = _CreateProtocolManager(fm, server.Protocol);
                    if (protocolManager == null) {
                        continue;
                    }

                    _ProtocolManagers.Add(protocolManager);
                    string password = null;
                    // only pass non-empty passwords to Connect()
                    if (!String.IsNullOrEmpty(server.Password)) {
                        password = server.Password;
                    }
                    protocolManager.Connect(fm, server.Hostname, server.Port,
                                            server.Username,
                                            password);
                    // if the connect command was correct, we should be able to get
                    // the chat model
                    if (protocolManager.Chat == null) {
                        fm.AddTextToChat(_SessionChat, String.Format(_("Automatic connect to {0} failed!"), server.Hostname + ":" + server.Port));
                        continue;
                    }

                    if (server.OnConnectCommands != null && server.OnConnectCommands.Count > 0) {
                        // copy the server variable into the loop scope, else it will always be the same object in the anonymous method!
                        ServerModel ser = server;
                        protocolManager.Connected += delegate {
                            foreach (string command in ser.OnConnectCommands) {
                                if (command.Length == 0) {
                                    continue;
                                }
                                CommandModel cd = new CommandModel(fm,
                                                                   protocolManager.Chat,
                                                                   (string)_UserConfig["Interface/Entry/CommandCharacter"],
                                                                   command);
                                protocolManager.Command(cd);
                            }
                        };
                    }
//.........这里部分代码省略.........
开发者ID:RoninBG,项目名称:smuxi,代码行数:101,代码来源:Session.cs

示例5: RegisterFrontendUI

        public void RegisterFrontendUI(IFrontendUI ui)
        {
            Trace.Call(ui);

            if (ui == null) {
                throw new ArgumentNullException("ui");
            }

            string uri = GetUri(ui);
            #if LOG4NET
            f_Logger.Debug("Registering UI with URI: " + uri);
            #endif
            // add the FrontendManager to the hashtable with an unique .NET remoting identifier
            FrontendManager fm = new FrontendManager(this, ui);
            lock (_FrontendManagers) {
                _FrontendManagers[uri] = fm;
            }

            // if this is the first frontend, we process OnStartupCommands
            if (!_OnStartupCommandsProcessed) {
                _OnStartupCommandsProcessed = true;

                string str;
                MessageModel msg;
                msg = new MessageModel();
                msg.MessageParts.Add(
                    new TextMessagePartModel(new TextColor(0xFF0000), null, false,
                            true, false, _("Welcome to Smuxi")));
                AddMessageToChat(_SessionChat, msg);

                msg = new MessageModel();
                msg.MessageParts.Add(
                    new TextMessagePartModel(null, null, false,
                            true, false, _("Type /help to get a list of available commands.")));
                AddMessageToChat(_SessionChat, msg);

                str = _("After you have made a connection the list of " +
                        "available commands changes. Use the /help command " +
                        "again to see the extended command list.");
                msg = new MessageModel();
                msg.MessageParts.Add(
                    new TextMessagePartModel(null, null, false,
                            true, false, str));
                AddMessageToChat(_SessionChat, msg);

                foreach (string command in (string[])_UserConfig["OnStartupCommands"]) {
                    if (command.Length == 0) {
                        continue;
                    }
                    CommandModel cd = new CommandModel(fm, _SessionChat,
                        (string)_UserConfig["Interface/Entry/CommandCharacter"],
                        command);
                    bool handled;
                    handled = Command(cd);
                    if (!handled) {
                        if (fm.CurrentProtocolManager != null) {
                            fm.CurrentProtocolManager.Command(cd);
                        }
                    }
                }

                // process server specific connects/commands
                ServerListController serverCon = new ServerListController(_UserConfig);
                IList<ServerModel> servers = serverCon.GetServerList();
                foreach (ServerModel server in servers) {
                    if (!server.OnStartupConnect) {
                        continue;
                    }

                    bool isError = false;
                    try {
                        IProtocolManager protocolManager = Connect(server, fm);

                        // if the connect command was correct, we should be
                        // able to get the chat model
                        if (protocolManager.Chat == null) {
                            isError = true;
                        }
                    } catch (Exception ex) {
            #if LOG4NET
                        f_Logger.Error("RegisterFrontendUI(): Exception during "+
                                       "automatic connect: ", ex);
            #endif
                        isError = true;
                    }
                    if (isError) {
                        fm.AddTextToChat(
                            _SessionChat,
                            String.Format(
                                _("Automatic connect to {0} failed!"),
                                server.Hostname + ":" + server.Port
                            )
                        );
                        continue;
                    }
                }
            }
        }
开发者ID:tuukka,项目名称:smuxi,代码行数:98,代码来源:Session.cs


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