mirror of
https://github.com/XLabsProject/s1x-client.git
synced 2023-08-02 15:02:12 +02:00
Prepare new server types
This commit is contained in:
parent
e361a50c53
commit
bdc26f6dce
42
src/client/game/demonware/servers/new/base_server.hpp
Normal file
42
src/client/game/demonware/servers/new/base_server.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include <utils/cryptography.hpp>
|
||||
|
||||
class base_server
|
||||
{
|
||||
public:
|
||||
base_server(std::string name)
|
||||
: name_(std::move(name))
|
||||
{
|
||||
this->address_ = utils::cryptography::jenkins_one_at_a_time::compute(this->name_);
|
||||
}
|
||||
|
||||
base_server(base_server&&) = delete;
|
||||
base_server(const base_server&) = delete;
|
||||
base_server& operator=(base_server&&) = delete;
|
||||
base_server& operator=(const base_server&) = delete;
|
||||
|
||||
virtual ~base_server() = default;
|
||||
|
||||
const std::string& get_name() const
|
||||
{
|
||||
return this->name_;
|
||||
}
|
||||
|
||||
uint32_t get_address() const
|
||||
{
|
||||
return this->address_;
|
||||
}
|
||||
|
||||
virtual void frame()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool pending_data()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
std::uint32_t address_ = 0;
|
||||
};
|
41
src/client/game/demonware/servers/new/tcp_server.hpp
Normal file
41
src/client/game/demonware/servers/new/tcp_server.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "base_server.hpp"
|
||||
|
||||
#include <queue>
|
||||
#include <utils/concurrency.hpp>
|
||||
|
||||
class tcp_server : public base_server
|
||||
{
|
||||
public:
|
||||
using base_server::base_server;
|
||||
|
||||
int handle_input(const char* buf, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_output(char* buf, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void handle(const std::string& data) = 0;
|
||||
void send(const std::string&)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
using stream_queue = std::queue<char>;
|
||||
using data_queue = std::queue<std::string>;
|
||||
|
||||
utils::concurrency::container<data_queue> in_queue_;
|
||||
utils::concurrency::container<stream_queue> out_queue_;
|
||||
|
||||
void frame() override
|
||||
{
|
||||
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user