-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathProgram.cs
70 lines (63 loc) · 2.34 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using MLAPI.ServerList.Client;
namespace ClientExample
{
class Program
{
static void Main(string[] args)
{
// Register 100 servers
for (int i = 0; i < 1000; i++)
{
ServerConnection advertConnection = new ServerConnection();
// Connect
advertConnection.Connect("127.0.0.1", 9423).AsyncWaitHandle.WaitOne();
// Create server data
Dictionary<string, object> data = new Dictionary<string, object>
{
{ "Players", (int)i },
{ "Name", "This is the name" }
};
// Register server
advertConnection.StartAdvertisment(data);
}
using (ServerConnection queryConnection = new ServerConnection())
{
// Connect
queryConnection.Connect("127.0.0.1", 9423);
// Send query
List<ServerModel> models = queryConnection.SendQuery(@"
{
""$and"": [
{
""Players"": {
""$gte"": 20
}
},
{
""Players"": {
""$lte"": 50
}
},
{
""Players"": {
""$in"": [
12,
13,
14,
23,
43,
51
]
}
}
]
}");
Console.WriteLine(string.Format("| {0,5} | {1,5} | {2,5} |", "UUID", "Name", "Players"));
Console.WriteLine(string.Join(Environment.NewLine, models.Select(x => string.Format("| {0,5} | {1,5} | {2,5} |", x.Id, x.ContractData["Name"], x.ContractData["Players"]))));
}
}
}
}