KlassischeKeplerKriege/game/network/session.hpp
2016-09-28 11:50:35 +02:00

37 lines
663 B
C++

#pragma once
#define ASIO_STANDALONE
#include <iostream>
#include <memory>
#include <utility>
#include <string>
#include <asio.hpp>
#include "game.hpp"
using asio::ip::tcp;
class Session
: public std::enable_shared_from_this<Session>
{
public:
Session(tcp::socket socket, game::State* state)
: m_socket(std::move(socket))
{
m_state = state;
}
void start();
private:
void do_read();
void do_write(char m_snd_data[], std::size_t length);
bool parse(std::string);
tcp::socket m_socket;
enum { max_length = 1024 };
char m_rcv_data[max_length];
game::State* m_state;
bool m_started = false;
int m_pid;
};