memgraph/include/bolt/v1/session.hpp

45 lines
805 B
C++
Raw Normal View History

2016-08-02 05:14:09 +08:00
#pragma once
#include "io/network/tcp/stream.hpp"
#include "io/network/socket.hpp"
#include "bolt/v1/states/state.hpp"
#include "bolt/v1/transport/bolt_decoder.hpp"
#include "bolt/v1/transport/bolt_encoder.hpp"
2016-08-08 04:19:04 +08:00
#include "bolt/v1/serialization/socket_serializer.hpp"
#include "bolt/v1/bolt.hpp"
2016-08-08 04:19:04 +08:00
2016-08-02 05:14:09 +08:00
#include "logging/default.hpp"
namespace bolt
{
class Session : public io::tcp::Stream<io::Socket>
{
public:
using Decoder = BoltDecoder;
2016-08-08 04:19:04 +08:00
using Encoder = SocketSerializer<io::Socket>;
2016-08-02 05:14:09 +08:00
Session(io::Socket&& socket, Bolt& bolt);
bool alive() const;
void execute(const byte* data, size_t len);
void close();
Bolt& bolt;
Db& active_db();
2016-08-02 05:14:09 +08:00
Decoder decoder;
Encoder encoder {socket};
bool connected {false};
State* state;
protected:
Logger logger;
};
}