forked from TheUnnameOrganization/PokemonGo.RocketAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.cs
More file actions
66 lines (54 loc) · 2.21 KB
/
Client.cs
File metadata and controls
66 lines (54 loc) · 2.21 KB
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
using System.Net;
using PokemonGo.RocketAPI.Enums;
using PokemonGo.RocketAPI.Extensions;
using PokemonGo.RocketAPI.HttpClient;
using POGOProtos.Networking.Envelopes;
namespace PokemonGo.RocketAPI
{
public class Client
{
public Rpc.Login Login;
public Rpc.Player Player;
public Rpc.Download Download;
public Rpc.Inventory Inventory;
public Rpc.Map Map;
public Rpc.Fort Fort;
public Rpc.Encounter Encounter;
public Rpc.Misc Misc;
public IApiFailureStrategy ApiFailure { get; set; }
public ISettings Settings { get; }
public string AuthToken { get; set; }
public static WebProxy Proxy;
public double CurrentLatitude { get; internal set; }
public double CurrentLongitude { get; internal set; }
public double CurrentAltitude { get; internal set; }
public AuthType AuthType => Settings.AuthType;
internal readonly PokemonHttpClient PokemonHttpClient;
internal string ApiUrl { get; set; }
internal AuthTicket AuthTicket { get; set; }
public Client(ISettings settings, IApiFailureStrategy apiFailureStrategy)
{
Settings = settings;
ApiFailure = apiFailureStrategy;
Proxy = InitProxy();
PokemonHttpClient = new PokemonHttpClient();
Login = new Rpc.Login(this);
Player = new Rpc.Player(this);
Download = new Rpc.Download(this);
Inventory = new Rpc.Inventory(this);
Map = new Rpc.Map(this);
Fort = new Rpc.Fort(this);
Encounter = new Rpc.Encounter(this);
Misc = new Rpc.Misc(this);
Player.SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
}
private WebProxy InitProxy()
{
if (!Settings.UseProxy) return null;
WebProxy prox = new WebProxy(new System.Uri($"http://{Settings.UseProxyHost}:{Settings.UseProxyPort}"), false, null);
if (Settings.UseProxyAuthentication)
prox.Credentials = new NetworkCredential(Settings.UseProxyUsername, Settings.UseProxyPassword);
return prox;
}
}
}