SQCSimulator2023/SQCSim-srv/connection.h

64 lines
1.4 KiB
C
Raw Normal View History

2023-09-24 11:07:03 -04:00
#ifndef CONNECTION_H__
#define CONNECTION_H__
2023-09-30 14:54:39 -04:00
2023-09-24 08:45:40 -04:00
#include <deque>
2023-11-06 13:56:12 -05:00
#include <unordered_map>
2023-09-24 08:45:40 -04:00
#include "../SQCSim-common/player.h"
#include "../SQCSim-common/vector3.h"
2023-09-25 16:30:03 -04:00
#include "../SQCSim-common/netprotocol.h"
#include "../SQCSim-common/world.h"
2023-09-24 08:45:40 -04:00
#include "define.h"
2023-10-25 12:16:14 -04:00
using namespace netprot;
2023-09-24 08:45:40 -04:00
class Connection {
public:
Connection(
SOCKET sock,
sockaddr_in sockaddr,
2023-10-25 12:16:14 -04:00
LoginInfo log,
PlayerInfo play);
2023-09-24 08:45:40 -04:00
~Connection();
2023-10-29 14:54:36 -04:00
std::unique_ptr<Player> player = nullptr;
2023-09-24 08:45:40 -04:00
2023-09-25 08:23:52 -04:00
uint64_t GetHash(bool self = true) const;
uint64_t GetTeamHash() const;
2023-09-24 08:45:40 -04:00
std::string GetName() const;
2023-10-25 12:16:14 -04:00
void AddInput(Input in);
Output* getOutput(Timestamp time);
Sync getSync(Timestamp time);
SOCKET getSock() const;
PlayerInfo* getInfo() const;
2023-10-26 17:57:42 -04:00
sockaddr_in* getAddr() const;
2023-09-24 11:07:03 -04:00
2023-11-06 17:59:57 -05:00
void getPacks(SOCKET sock);
void sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns);
void Run(World* world);
2023-09-24 11:07:03 -04:00
void CleanInputManifest(Timestamp time);
2023-11-24 15:32:53 -05:00
bool m_nsync = true;
2023-09-24 08:45:40 -04:00
private:
2023-11-06 13:56:12 -05:00
std::unordered_map<Timestamp, Input> m_input_manifest;
2023-11-24 14:15:40 -05:00
std::vector<Input> m_input_vector;
2023-11-06 13:56:12 -05:00
std::unordered_map<Timestamp, Output> m_output_manifest;
2023-11-24 14:15:40 -05:00
std::vector<Output> m_output_vector;
2023-11-06 13:56:12 -05:00
std::unordered_map<Timestamp, Chat> m_chatlog;
2023-10-23 16:21:15 -04:00
SOCKET m_sock;
sockaddr_in m_addr;
2023-10-25 12:16:14 -04:00
LoginInfo m_loginfo;
PlayerInfo m_playinfo;
2023-09-24 08:45:40 -04:00
2023-11-06 17:59:57 -05:00
Timestamp m_startsync;
uint64_t m_last_in = 0,
m_last_out = 0;
Buffer m_buf,
m_bufout;
2023-09-24 08:45:40 -04:00
};
2023-10-26 17:57:42 -04:00
#endif