本文整理汇总了C#中Client.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Client.Dispose方法的具体用法?C# Client.Dispose怎么用?C# Client.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.Dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Disconnect
internal static void Disconnect(Client c) {
//if (c.policy == 1) {
// foreach (var s in users) {
// s.Send($"<l u=\"{c.id}\" />\0");
// }
//}
users.Remove(c);
c.Dispose();
}
示例2: TestClientRestarting
public void TestClientRestarting()
{
Client client = new Client();
client.Start();
client.Stop();
client.ToString(); // shouldn't throw an exception
client.Start();
client.Stop();
client.Dispose();
client.ToString();
}
示例3: Main
public static void Main () {
client = new Client ();
Console.WriteLine ("joined service name: " + Client.JoinServiceName ("FooBar", "_foo", "local"));
EntryGroup eg = new EntryGroup (client);
eg.StateChanged += OnEntryGroupChanged;
eg.AddService ("foobar2", "_dingdong._tcp", client.DomainName,
444, new string[] { "foo=stuff", "bar=stuff2", "baz=stuff3" });
eg.Commit ();
BrowseServiceTypes ("local");
Console.WriteLine ("Press enter to quit");
Console.ReadLine ();
client.Dispose ();
}
示例4: CanUseProfiles
public void CanUseProfiles()
{
var client = new Client(new Uri(AmeeUrl), AmeeUserName, AmeePassword);
var profile = client.CreateProfile();
var profiles = client.GetProfiles();
Assert.Greater(profiles.Profiles.Length, 0);
foreach (var p in profiles.Profiles)
{
client.DeleteProfile(p.Uid);
}
profiles = client.GetProfiles();
Assert.AreEqual(0, profiles.Profiles.Length);
client.Dispose();
}
示例5: J2
///TODO
//Add mobile checking
//Add Bot Protection
///
private static async void J2(Dictionary<string, object> data, Client user) {
if (!user.authenticated && user.loginKeys.Count > 0) {
try {
for (int i = 0; i < Config.pcount; i++) {
var d = $"d{i + 4}";
var m = $"m{i}";
if (data.ContainsKey((string)data[d]))
user.powersV["enabled"].Add(int.Parse((string)data[d]));
else
user.powersV["enabled"].Add(0);
if (data.ContainsKey((string)data[m]))
user.powersV["disabled"].Add(int.Parse((string)data[m]));
else
user.powersV["disabled"].Add(0);
user.userid = int.Parse((string)data["u"]);
if (data.ContainsKey("d0"))
user.d0 = int.Parse((string)data["u"]);
user.K = int.Parse((string)data["k"]);
if (data.ContainsKey("pool"))
user.pool = int.Parse((string)data["pool"]);
user.home = (string)data["h"];
user.avatar = (string)data["a"];
user.roomID = int.Parse((string)data["c"]);
user.nick = (string)data["n"];
if (data.ContainsKey("r"))
user.chatPass = (string)data["r"];
if (user.userid == 2) {
user.guest = true;
user.f = 0;
} else {
if (await Database.Open()) {
var u = await Database.FetchArray($"SELECT * FROM users WHERE id='{user.userid}' and k='{user.K}'");
if (u.Count <= 1) {
await Database.Close();
user.Dispose();
return;
}
user.guest = string.IsNullOrWhiteSpace((string)u["username"]);
user.userid = int.Parse((string)u["id"]);
user.d2 = int.Parse((string)u["d2"]);
user.xats = int.Parse((string)u["xats"]);
user.days = int.Parse((string)u["days"] ) - 1453848182 / 86400;
user.pawn = (string)u["custpawn"];
user.bride = int.Parse((string)u["bride"]);
user.uName = (string)u["username"];
user.uPass = (string)u["password"];
if(user.days > 0 ) {
//Get powers
}
if(!user.guest) {
await Database.query($"UPDATE users set nickname='{user.nick}', avatar='{user.avatar}', url='{user.home}', connectedlast='{user.client.Client.RemoteEndPoint}' WHERE id='{user.userid}'");
}
user.f = int.Parse((string)data["f"]);
user.authenticated = true;
await Database.Close();
await user.joinRoom(user.roomID);
}
}
}
} catch (Exception ex) {
Console.WriteLine(ex.Message);
user.Dispose();
}
}
}
示例6: Execute
public override void Execute(Server server, Client client, string args)
{
client.Send("Bye!", false);
client.Debug("Got exit command, disposing");
client.Dispose();
}