mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 23:47:21 +00:00
5942182486
* Logger: Rename logger to Logger from dLogger * Logger: Add compile time filename Fix include issues Add writers Add macros Add macro to force compilation * Logger: Replace calls with macros Allows for filename and line number to be logged * Logger: Add comments and remove extra define Logger: Replace with unique_ptr also flush console at exit. regular file writer should be flushed on file close. Logger: Remove constexpr on variable * Logger: Simplify code * Update Logger.cpp
105 lines
2.8 KiB
C++
105 lines
2.8 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include "RakPeerInterface.h"
|
|
#include "ReplicaManager.h"
|
|
#include "NetworkIDManager.h"
|
|
|
|
class Logger;
|
|
class dConfig;
|
|
enum class eServerDisconnectIdentifiers : uint32_t;
|
|
|
|
enum class ServerType : uint32_t {
|
|
Master,
|
|
Auth,
|
|
Chat,
|
|
World
|
|
};
|
|
|
|
class dServer {
|
|
public:
|
|
// Default constructor should only used for testing!
|
|
dServer() {};
|
|
dServer(
|
|
const std::string& ip,
|
|
int port,
|
|
int instanceID,
|
|
int maxConnections,
|
|
bool isInternal,
|
|
bool useEncryption,
|
|
Logger* logger,
|
|
const std::string masterIP,
|
|
int masterPort,
|
|
ServerType serverType,
|
|
dConfig* config,
|
|
bool* shouldShutdown,
|
|
unsigned int zoneID = 0);
|
|
~dServer();
|
|
|
|
Packet* ReceiveFromMaster();
|
|
Packet* Receive();
|
|
void DeallocatePacket(Packet* packet);
|
|
void DeallocateMasterPacket(Packet* packet);
|
|
virtual void Send(RakNet::BitStream* bitStream, const SystemAddress& sysAddr, bool broadcast);
|
|
void SendToMaster(RakNet::BitStream* bitStream);
|
|
|
|
void Disconnect(const SystemAddress& sysAddr, eServerDisconnectIdentifiers disconNotifyID);
|
|
|
|
bool IsConnected(const SystemAddress& sysAddr);
|
|
const std::string& GetIP() const { return mIP; }
|
|
const int GetPort() const { return mPort; }
|
|
const int GetMaxConnections() const { return mMaxConnections; }
|
|
const bool GetIsEncrypted() const { return mUseEncryption; }
|
|
const bool GetIsInternal() const { return mIsInternal; }
|
|
const bool GetIsOkay() const { return mIsOkay; }
|
|
Logger* GetLogger() const { return mLogger; }
|
|
const bool GetIsConnectedToMaster() const { return mMasterConnectionActive; }
|
|
const unsigned int GetZoneID() const { return mZoneID; }
|
|
const int GetInstanceID() const { return mInstanceID; }
|
|
ReplicaManager* GetReplicaManager() { return mReplicaManager; }
|
|
void UpdateReplica();
|
|
void UpdateBandwidthLimit();
|
|
void UpdateMaximumMtuSize();
|
|
|
|
int GetPing(const SystemAddress& sysAddr) const;
|
|
int GetLatestPing(const SystemAddress& sysAddr) const;
|
|
|
|
NetworkIDManager* GetNetworkIDManager() { return mNetIDManager; }
|
|
|
|
const ServerType GetServerType() const { return mServerType; }
|
|
|
|
private:
|
|
bool Startup();
|
|
void Shutdown();
|
|
void SetupForMasterConnection();
|
|
bool ConnectToMaster();
|
|
|
|
private:
|
|
Logger* mLogger = nullptr;
|
|
dConfig* mConfig = nullptr;
|
|
RakPeerInterface* mPeer = nullptr;
|
|
ReplicaManager* mReplicaManager = nullptr;
|
|
NetworkIDManager* mNetIDManager = nullptr;
|
|
|
|
/**
|
|
* Whether or not to shut down the server. Pointer to Game::shouldShutdown.
|
|
*/
|
|
bool* mShouldShutdown = nullptr;
|
|
SocketDescriptor mSocketDescriptor;
|
|
std::string mIP;
|
|
int mPort;
|
|
int mMaxConnections;
|
|
unsigned int mZoneID;
|
|
int mInstanceID;
|
|
bool mUseEncryption;
|
|
bool mIsInternal;
|
|
bool mIsOkay;
|
|
bool mMasterConnectionActive;
|
|
ServerType mServerType;
|
|
|
|
RakPeerInterface* mMasterPeer = nullptr;
|
|
SocketDescriptor mMasterSocketDescriptor;
|
|
SystemAddress mMasterSystemAddress;
|
|
std::string mMasterIP;
|
|
int mMasterPort;
|
|
};
|