當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。