本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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);
}
};
}
//.........这里部分代码省略.........
示例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;
}
}
}
}