本文整理汇总了C#中IrcDotNet.IrcClient.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# IrcClient.Disconnect方法的具体用法?C# IrcClient.Disconnect怎么用?C# IrcClient.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IrcDotNet.IrcClient
的用法示例。
在下文中一共展示了IrcClient.Disconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleEventLoop
private static void HandleEventLoop(IrcClient client)
{
_ircLocaluser = client.LocalUser;
_hostNameToWebSockets.Add("", new WebSocketListenerClient(PrivateConstants.TestAccountWebsocketAuth));
_hostNameToWebSockets[""].Run(sendToIrcProcessor);
bool isExit = false;
while (!isExit) {
Console.Write("> ");
var command = Console.ReadLine();
switch (command) {
case "exit":
isExit = true;
break;
default:
if (!string.IsNullOrEmpty(command)) {
if (command.StartsWith("/") && command.Length > 1) {
client.SendRawMessage(command.Substring(1));
} else {
Console.WriteLine($"Unknown command '{command}'");
}
}
break;
}
}
client.Disconnect();
}
示例2: Irc
public ActionResult Irc()
{
var api = new AppHarborApi(new AuthInfo { AccessToken = ConfigurationManager.AppSettings["authToken"] });
var latestBuild = api.GetBuilds(Constants.AppHarborAppName).First();
var testResults = api.GetTests(Constants.AppHarborAppName, latestBuild.ID);
List<AppHarbor.Model.Test> allTests = new List<AppHarbor.Model.Test>();
foreach (var testresult in testResults)
{
FillTests(allTests, testresult);
}
AutoResetEvent are = new AutoResetEvent(false);
IrcDotNet.IrcClient client = new IrcDotNet.IrcClient();
try
{
client.Connect("irc.gamesurge.net", false, new IrcUserRegistrationInfo() { NickName = "crymono-build", RealName = "crymono", UserName = "crymono" });
client.ClientInfoReceived += (s, e) => are.Set();
are.WaitOne();
client.Channels.Join(new string[] { "#crymono" });
Thread.Sleep(200);
string msg = latestBuild.Commit.Message.Replace("\n", "").Replace("\r", "");
client.LocalUser.SendMessage("#crymono", "Build finished, latest commit: " + msg);
Thread.Sleep(200);
int numPassedTests = allTests.Count(t => t.Status == "Passed");
float percentage = (float)numPassedTests / allTests.Count * 100;
client.LocalUser.SendMessage("#crymono", String.Format("Test results: {0} of {1} passed ({2:0}%) - http://crymono.apphb.com/#!/{3} - AppHB: https://appharbor.com/applications/crymonobuild/builds/{3}/tests",
numPassedTests,
allTests.Count,
percentage,
latestBuild.ID
));
Thread.Sleep(200);
}
finally
{
if (client != null && client.IsConnected)
{
client.Quit("to the hills!");
Thread.Sleep(200);
client.Disconnect();
}
}
return Content("OK");
}
示例3: Bot
public Bot()
{
commands = Command.GetCommands(this);
IsInChannel = false;
IsIdentified = false;
IsRunning = true;
// Initialize commands
foreach(Command command in commands)
command.Initialize();
client = new IrcClient
{
FloodPreventer = new IrcStandardFloodPreventer(4, 2000)
};
// TODO Nasty...
connectedEvent = new ManualResetEventSlim(false);
client.Connected += (sender, e) => connectedEvent.Set();
client.Connected += (sender, args) => Console.WriteLine("Connected!");
client.Disconnected += (sender, args) =>
{
const int MaxRetries = 16;
int tries = 0;
if (!IsRunning)
{
Console.WriteLine("Disconnected and IsRunning == false, assuming graceful shutdown...");
return;
}
IsInChannel = false;
IsIdentified = false;
// Wait a little so the server doesn't block us from rejoining (flood control)
Console.WriteLine("Lost connection, attempting to reconnect in 6 seconds...");
client.Disconnect();
Thread.Sleep(6000);
// Reconnect
Console.Write("Reconnecting... ");
while (!Connect(Configuration.Server) && tries++ < MaxRetries)
{
Console.Write("\rReconnecting, attempt {0}...", tries);
Thread.Sleep(1);
}
if (tries == MaxRetries)
{
Console.WriteLine("Failed.");
Quit("Failed to reconnect.");
return;
}
Console.WriteLine("Connected");
Console.Write("Joining channel... ");
if (JoinChannel(Configuration.Channel))
Console.WriteLine("Success");
else
{
Console.WriteLine("Failed");
Quit("Failed to rejoin channel.");
}
};
client.Registered += (sender, args) =>
{
IrcClient localClient = (IrcClient)sender;
// Identify with server
client.SendRawMessage(String.Format("ns identify {0}", Configuration.Password));
localClient.LocalUser.NoticeReceived += (o, eventArgs) =>
{
if (eventArgs.Text.StartsWith("Password accepted"))
IsIdentified = true;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(eventArgs.Text);
Console.ForegroundColor = ConsoleColor.Gray;
};
localClient.LocalUser.JoinedChannel += (o, eventArgs) =>
{
IrcChannel channel = localClient.Channels.FirstOrDefault();
if (channel == null)
return;
Console.WriteLine("Joined channel!");
channel.MessageReceived += HandleMessage;
channel.UserJoined += (sender1, userEventArgs) =>
{
string joinMessage = String.Format("Used joined: {0}", userEventArgs.Comment ?? "No comment");
foreach (Command command in commands)
command.HandlePassive(joinMessage, userEventArgs.ChannelUser.User.NickName);
};
//.........这里部分代码省略.........
示例4: TravisCi
//.........这里部分代码省略.........
if (line.Equals("-- START TEST RUN --"))
{
buildResult = true;
} else if (line.StartsWith("Tests run: "))
{
summary = line + " - " + stringReader.ReadLine();
}
else if (line.Equals("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>"))
{
string xmlContents = stringReader.ReadToEnd();
xmlContents = xmlContents.Substring(0, xmlContents.IndexOf("</test-results>")+15);
XDocument doc = XDocument.Parse(xmlContents);
AutoResetEvent are = new AutoResetEvent(false);
IrcDotNet.IrcClient client = new IrcDotNet.IrcClient();
try
{
client.Connect("irc.gamesurge.net", false, new IrcUserRegistrationInfo() { NickName = "inkdev-build", RealName = "crymono", UserName = "crymono" });
client.ClientInfoReceived += (s, e) => are.Set();
are.WaitOne();
//client.Channels.Join(new string[] { "#crymono" });
Thread.Sleep(200);
//string msg = latestBuild.Commit.Message.Replace("\n", "").Replace("\r", "");
string msg = "hello";
string buildStatus = buildResult ? "OK" : "FAILED";
client.LocalUser.SendMessage("#crymonobuild", String.Format("Travis build completed. Build: {0} - http://travis-ci.org/inkdev/CryMono/builds/{1}", buildStatus,buildId));
Thread.Sleep(200);
var testResultsElement = doc.Element("test-results");
client.LocalUser.SendMessage("#crymonobuild", String.Format("Tests run: {0}, Errors: {1}, Failures: {2}, Inconclusive: {3}, Not run: {4}, Invalid: {5}, Ignored: {6}, Skipped: {7}, Time: {8}s",
testResultsElement.Attribute("total").Value,
testResultsElement.Attribute("errors").Value,
testResultsElement.Attribute("failures").Value,
testResultsElement.Attribute("inconclusive").Value,
testResultsElement.Attribute("not-run").Value,
testResultsElement.Attribute("invalid").Value,
testResultsElement.Attribute("ignored").Value,
testResultsElement.Attribute("skipped").Value,
doc.Descendants("test-suite").First().Attribute("time").Value
));
Thread.Sleep(500);
var failingTests =
doc.Descendants("test-case").Where(
x =>
x.Attribute("success").Value == "False" &&
x.Descendants().Any(d => d.Name == "failure")).Take(3);
foreach (var item in failingTests)
{
client.LocalUser.SendMessage("#crymonobuild", String.Format("{0}: {1}",
item.Attribute("name").Value,
item.Element("failure").Element("message").Value.Replace("\n","")));
Thread.Sleep(500);
}
if (payload == null)
{
client.LocalUser.SendMessage("#crymonobuild", "Something wrong: " + String.Join(",",Request.Form.AllKeys));
}
else
{
client.LocalUser.SendMessage("#crymonobuild",
"Debug for ins\\: " + payload);
}
Thread.Sleep(5000);
}
finally
{
if (client != null && client.IsConnected)
{
client.Quit("to the hills!");
Thread.Sleep(200);
client.Disconnect();
}
}
break;
}
line = stringReader.ReadLine();
}
}
}
return Content("What?");
}