-
Notifications
You must be signed in to change notification settings - Fork 7
Network
Andrey edited this page Jun 2, 2023
·
11 revisions
The game interacts with the server via the http protocol.
There are ready-made methods of popular queries for you in the library, they are implemented in the GameClient
class
The client is created through the constructor
Parameter | Type | Description | Default |
---|---|---|---|
identifierQuery | IdentifierQuery | Represents a uuid and udid parameters of the client |
null (IdentifierQuery.Default ) |
onlineQuery | OnlineQuery | Represents a gameVersion , binaryVersion , gdw and secret parameters of the client |
null (OnlineQuery.Default ) |
network | Network | The class that allows you to make http requests to the server Learn more |
null (new Network() ) |
To interact with the official game server
var client = new GameClient();
var server = new GameServer(
network: new Network(server: "http://game.gdpseditor.com/server")
);
var user = await client.SearchUserAsync("user name");
var account = await client.GetAccountAsync(accountId: 71);
You can get the accountId
from the user search
var user = await client.SearchUserAsync("user name");
if (user.GeometryDashStatusCode != 0)
Console.WriteLine("error when searching for a user");
var account = await client.GetAccountAsync(user.GetResultOrDefault().User.AccountId);
var comments = await client.GetAccountCommentsAsync(accountId: 71, page: 0);
foreach (var comment in comments.GetResultOrDefault().Comments)
Console.WriteLine($"{comment.Date}: {comment.Comment}");
var response = await client.LoginAsync("user", "password");
var login = response.GetResultOrDefault();
See Login for get login
field
var levelsPage = await client.GetMyLevelsAsync(new PasswordQuery(login.AccountId, "password"), login.UserId, 0);
var levelResponse = await client.DownloadLevelAsync(id: 29441648);
So that you can edit the blocks and colors of the level, you need to create a Level
var level = new Level(levelResponse.GetResultOrDefault().Level.LevelString, compressed: true);
The Network
class represents interaction over the http protocol
You can create Network
like this
var network = new Network(server, httpClientFactory, responseFilter);
Parameter | Type | Description | Default |
---|---|---|---|
server | string | The base url to the server to which requests will be sent | http://www.boomlings.com/database |
httpClientFactory | IFactory<HttpClient> | A factory for creating http clients, with which you can configure timeouts, headers, and so on Learn more to create your own http client factory |
null (DefaultHttpClientFactory) |
responseFilter | Func<string, bool> | Useless feature for manually filtering the response (For example, if suddenly cloudflare gives you html) | null |
using System;
using System.Net.Http;
public class YourHttpFactory : IFactory<HttpClient>
{
public HttpClient Create()
{
return new HttpClient()
{
Timeout = TimeSpan.FromSeconds(20),
};
}
}