blob: 9f59c37680dc0294b437613ed908ecc0a2ccb783 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#pragma once
#include "Configuration/UnityConfigure.h"
#if ENABLE_NETWORK
#include "Runtime/GameCode/Behaviour.h"
#include "NetworkEnums.h"
#include "External/RakNet/builds/include/RakPeerInterface.h"
#include "External/RakNet/builds/include/LightweightDatabaseClient.h"
#include "External/RakNet/builds/include/MessageIdentifiers.h"
#include "Runtime/BaseClasses/ManagerContext.h"
#include <vector>
const int CELL_COUNT=8;
class MasterServerInterface : public GlobalGameManager
{
public:
REGISTER_DERIVED_CLASS (MasterServerInterface, GlobalGameManager)
typedef std::vector<HostData> HostList;
MasterServerInterface(MemLabelId label, ObjectCreationMode mode);
// ~MasterServerInterface(); declared-by-macro
virtual void NetworkOnApplicationQuit();
virtual void NetworkUpdate();
void ClientConnect();
void ServerConnect();
bool CheckServerConnection();
void QueryHostList();
void QueryHostList(string gameType);
void ClearHostList();
void RegisterHost(string gameType, string gameName, string comment);
void SendHostUpdate();
void UnregisterHost();
void Disconnect();
HostList PollHostList();
void ProcessPacket(Packet *packet);
void ResetHostState();
string GetIPAddress() { return string(m_MasterServerID.ToString(false)); }
void SetIPAddress(std::string address) { m_MasterServerID.SetBinaryAddress(address.c_str()); }
int GetPort() { return m_MasterServerID.port; }
void SetPort(int port) { m_MasterServerID.port = port; }
SystemAddress& GetMasterServerID() { return m_MasterServerID; }
void SetUpdateRate(int rate) { m_UpdateRate = rate; }
int GetUpdateRate() { return m_UpdateRate; }
bool PopulateUpdate();
bool PopulateUpdate(string gameName, string comment);
void SetDedicatedServer(bool value) { m_IsDedicatedServer = value; };
bool GetDedicatedServer() { return m_IsDedicatedServer; };
private:
void ResolveMasterServerAddress();
RakPeerInterface *m_Peer;
LightweightDatabaseClient m_DatabaseClient;
LightweightDatabaseClient *m_HostDatabaseClient;
bool m_PendingRegister;
bool m_PendingQuery;
bool m_PendingHostUpdate;
string m_GameType;
string m_HostName;
string m_HostComment;
HostList m_HostList;
unsigned int m_RowID;
bool m_Registered;
time_t m_LastHostUpdateTime;
SystemAddress m_MasterServerID;
char m_Version[3];
int m_UpdateRate;
DatabaseCellUpdate m_LastUpdate[CELL_COUNT];
bool m_IsDedicatedServer;
time_t m_ShutdownTimer;
};
MasterServerInterface* GetMasterServerInterfacePtr ();
MasterServerInterface& GetMasterServerInterface ();
#endif
|