Joedb 10.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Server_Client.h
Go to the documentation of this file.
1#ifndef joedb_Server_Client_declared
2#define joedb_Server_Client_declared
3
6#include "joedb/Thread_Safe.h"
10
11#include <chrono>
12
13namespace joedb
14{
15 /// @ingroup concurrency
16 class Server_Client: public Logger, public Ping_Client
17 {
18 friend class Server_File;
19
20 private:
21 void locked_ping(Lock<Channel&> &lock) override final;
22 Keep_Alive_Thread keep_alive;
23
24 void connect();
25 void disconnect();
26
27 protected:
30
32
33 int64_t session_id;
36
37 void download
38 (
39 Async_Writer &writer,
40 Lock<Channel&> &lock,
41 int64_t size
42 ) const;
43
44 void log(beman::cstring_view message) noexcept override;
45
46 public:
47 ///
48 /// @param keep_alive_interval: a background thread will send a ping
49 /// to the server at this interval. Setting this parameter to zero disables
50 /// the keep-alive background thread.
51 ///
53 (
56 std::chrono::milliseconds keep_alive_interval = std::chrono::milliseconds(0)
57 );
58
59 int64_t get_session_id() const {return session_id;}
60 Thread_Safe<Channel&> &get_channel() override final {return channel;}
61
63 };
64}
65
66#endif
static Logger dummy_logger
Definition Logger.h:14
friend class Keep_Alive_Thread
void log(beman::cstring_view message) noexcept override
Thread_Safe< Channel & > channel
Server_Client(Channel &channel, Logger &logger=Logger::dummy_logger, std::chrono::milliseconds keep_alive_interval=std::chrono::milliseconds(0))
Thread_Safe< Channel & > & get_channel() override final
void download(Async_Writer &writer, Lock< Channel & > &lock, int64_t size) const
int64_t get_session_id() const
friend class Server_File