File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 11
11
<RepositoryUrl >https://github.com/Folleach/GeometryDashAPI</RepositoryUrl >
12
12
<RepositoryType >git</RepositoryType >
13
13
<PackageTags >api, geometry, dash</PackageTags >
14
- <PackageVersion >0.1.12 </PackageVersion >
14
+ <PackageVersion >0.1.13 </PackageVersion >
15
15
<LangVersion >9</LangVersion >
16
16
<AllowUnsafeBlocks >true</AllowUnsafeBlocks >
17
17
</PropertyGroup >
Original file line number Diff line number Diff line change @@ -10,16 +10,17 @@ public class GameServer
10
10
{
11
11
private readonly IdentifierQuery identifierQuery ;
12
12
private readonly OnlineQuery onlineQuery ;
13
- private readonly Network network = new ( ) ;
13
+ private readonly Network network ;
14
14
15
- public GameServer ( )
15
+ public GameServer ( ) : this ( null )
16
16
{
17
17
}
18
18
19
- public GameServer ( IdentifierQuery identifierQuery = null , OnlineQuery onlineQuery = null )
19
+ public GameServer ( IdentifierQuery identifierQuery = null , OnlineQuery onlineQuery = null , Network network = null )
20
20
{
21
21
this . identifierQuery = identifierQuery ;
22
22
this . onlineQuery = onlineQuery ;
23
+ this . network = network ?? new Network ( ) ;
23
24
}
24
25
25
26
public async Task < ServerResponse < TopResponse > > GetTop ( TopType type , int count )
Original file line number Diff line number Diff line change 1
- using System . IO ;
1
+ using System ;
2
+ using System . IO ;
2
3
using System . Net ;
3
4
using System . Text ;
4
5
using System . Threading . Tasks ;
5
6
6
7
namespace GeometryDashAPI . Server
7
8
{
8
- internal class Network
9
+ public class Network
9
10
{
11
+ private readonly Action < HttpWebRequest > configurator ;
10
12
public Encoding DataEncoding { get ; }
11
13
public int Timeout { get ; set ; } = 30_000 ;
12
14
13
15
public Network ( ) : this ( Encoding . ASCII )
14
16
{
15
17
}
16
18
17
- public Network ( Encoding encoding )
19
+ public Network ( Encoding encoding , Action < HttpWebRequest > configurator = null )
18
20
{
19
21
DataEncoding = encoding ;
22
+ this . configurator = configurator ;
20
23
}
21
24
22
25
public async Task < ( HttpStatusCode statusCode , string body ) > GetAsync ( string path , IQuery query )
@@ -31,6 +34,7 @@ public Network(Encoding encoding)
31
34
client . Method = "POST" ;
32
35
client . Timeout = Timeout ;
33
36
client . Accept = "*/*" ;
37
+ configurator ? . Invoke ( client ) ;
34
38
var data = DataEncoding . GetBytes ( properties . ToString ( ) ) ;
35
39
var requestStream = await client . GetRequestStreamAsync ( ) ;
36
40
await requestStream . WriteAsync ( data , 0 , data . Length ) ;
You can’t perform that action at this time.
0 commit comments