X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=server.cpp;h=9c4219a4789d263bc2d8b61a8d8e65143d717bad;hp=6dcddf0b4431e983909e012cb863636f6ccab635;hb=20e478b83e754fd9b19d58abe79732fa0dd20ffc;hpb=771355dc2b3ac9d076482148a03591debb97f62e diff --git a/server.cpp b/server.cpp index 6dcddf0..9c4219a 100644 --- a/server.cpp +++ b/server.cpp @@ -18,6 +18,7 @@ #include "metacube.h" #include "server.h" #include "mutexlock.h" +#include "state.pb.h" using namespace std; @@ -28,6 +29,30 @@ Client::Client(int sock) { request.reserve(1024); } + +Client::Client(const ClientProto &serialized) + : sock(serialized.sock()), + state(State(serialized.state())), + request(serialized.request()), + stream_id(serialized.stream_id()), + header(serialized.header()), + header_bytes_sent(serialized.header_bytes_sent()), + bytes_sent(serialized.bytes_sent()) +{ +} + +ClientProto Client::serialize() const +{ + ClientProto serialized; + serialized.set_sock(sock); + serialized.set_state(state); + serialized.set_request(request); + serialized.set_stream_id(stream_id); + serialized.set_header(header); + serialized.set_header_bytes_sent(serialized.header_bytes_sent()); + serialized.set_bytes_sent(bytes_sent); + return serialized; +} Server::Server() {