本文整理汇总了C#中IrcClient.Listen方法的典型用法代码示例。如果您正苦于以下问题:C# IrcClient.Listen方法的具体用法?C# IrcClient.Listen怎么用?C# IrcClient.Listen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IrcClient
的用法示例。
在下文中一共展示了IrcClient.Listen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IrcClientList
public static void IrcClientList()
{
IrcClient irc = new IrcClient();
irc.OnRawMessage += new IrcEventHandler(IrcClientListCallback);
irc.Connect(SERVER, PORT);
irc.Login(NICK, REALNAME);
irc.RfcList(CHANNEL);
irc.Listen();
}
示例2: Main
static void Main()
{
var client = new IrcClient() {
ActiveChannelSyncing = true
};
client.Connect("irc.oftc.net", 6667);
client.Login("smuxi-bot", "smuxi bot");
client.OnRegistered += delegate {
client.RfcJoin("#smuxi");
};
var client2 = new IrcClient() {
ActiveChannelSyncing = true
};
client2.Connect("irc.freenode.net", 6667);
client2.Login("smuxi-bot", "smuxi bot");
client2.OnRegistered += delegate {
client2.RfcJoin("#smuxi");
};
var timer = new Timer(delegate {
var chan = client.GetChannel("#smuxi");
var chan2 = client2.GetChannel("#smuxi");
if (chan == null) {
client.RfcJoin("#smuxi");
return;
}
if (chan2 == null) {
client2.RfcJoin("#smuxi");
return;
}
// filter duplicates and clones
var users = new List<string>();
foreach (string user in chan.Users.Keys) {
var nick = user.TrimEnd('_');
users.Add(nick);
};
foreach (string user in chan2.Users.Keys) {
var nick = user.TrimEnd('_');
if (users.Contains(nick)) {
continue;
}
users.Add(nick);
}
Console.WriteLine("{0} #smuxi user count: {1}",
DateTime.Now.ToString("s"), users.Count);
}, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
var thread = new Thread(new ThreadStart(delegate {
while (client.IsConnected) {
client.Listen();
Thread.Sleep(1000);
}
}));
thread.Start();
var thread2 = new Thread(new ThreadStart(delegate {
while (client2.IsConnected) {
client2.Listen();
Thread.Sleep(1000);
}
}));
thread2.Start();
thread.Join();
thread2.Join();
}