#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;
    size_t m_pid;
};
