1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:23:51 +00:00
openmw-tes3mp/apps/browser/netutils/QueryClient.hpp

47 lines
1.2 KiB
C++
Raw Normal View History

2017-04-27 03:30:51 +00:00
//
// Created by koncord on 24.04.17.
//
#ifndef OPENMW_QUERYCLIENT_HPP
#define OPENMW_QUERYCLIENT_HPP
#include <string>
#include <RakPeerInterface.h>
#include <components/openmw-mp/Master/PacketMasterQuery.hpp>
#include <components/openmw-mp/Master/PacketMasterUpdate.hpp>
#include <apps/browser/ServerModel.hpp>
#include <mutex>
2017-04-27 03:30:51 +00:00
class QueryClient
{
public:
2017-04-27 03:30:51 +00:00
QueryClient(QueryClient const &) = delete;
QueryClient(QueryClient &&) = delete;
QueryClient &operator=(QueryClient const &) = delete;
QueryClient &operator=(QueryClient &&) = delete;
2017-04-27 03:30:51 +00:00
static QueryClient &Get();
void SetServer(const std::string &addr, unsigned short port);
2017-04-27 03:30:51 +00:00
std::map<RakNet::SystemAddress, QueryData> Query();
std::pair<RakNet::SystemAddress, QueryData> Update(const RakNet::SystemAddress &addr);
2017-04-27 03:30:51 +00:00
int Status();
private:
RakNet::ConnectionState Connect();
MASTER_PACKETS GetAnswer(MASTER_PACKETS packet);
2017-04-27 03:30:51 +00:00
protected:
QueryClient();
~QueryClient();
private:
int status;
RakNet::RakPeerInterface *peer;
RakNet::SystemAddress masterAddr;
mwmp::PacketMasterQuery *pmq;
mwmp::PacketMasterUpdate *pmu;
std::pair<RakNet::SystemAddress, ServerData> server;
std::mutex mxServers;
2017-04-27 03:30:51 +00:00
};
#endif //OPENMW_QUERYCLIENT_HPP