-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHttpClientConnection
More file actions
60 lines (46 loc) · 1.64 KB
/
HttpClientConnection
File metadata and controls
60 lines (46 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Copyright (C) 2021 Frank Mertens.
*
* Distribution and use is allowed under the terms of the GNU General Public License version 3
* (see CoreComponents/LICENSE-gpl-3.0).
*
*/
#pragma once
#include <cc/StreamSocket>
namespace cc {
/** \internal
* \class HttpClientConnection cc/HttpClientConnection
* \ingroup http_server
* \brief %Connection information needed for connection queueing
*/
class HttpClientConnection final: public Object
{
public:
HttpClientConnection() = default;
explicit HttpClientConnection(const StreamSocket &stream, const SocketAddress &localAddress):
Object{new State{stream, localAddress}}
{}
StreamSocket stream() const { return me().stream_; }
SocketAddress localAddress() const { return me().localAddress_; }
SocketAddress peerAddress() const { return me().stream_.address(); }
int priority() const { return me().priority_; }
void setPriority(int newPriority) { me().priority_ = newPriority; }
uint64_t originAddress() const { return me().originAddress_; }
double arrivalTime() const { return me().arrivalTime_; }
double departureTime() const { return me().departureTime_; }
void updateDepartureTime();
private:
struct State: public Object::State
{
State(const StreamSocket &stream, const SocketAddress &localAddress);
StreamSocket stream_;
SocketAddress localAddress_;
int priority_;
uint64_t originAddress_;
double arrivalTime_;
double departureTime_;
};
State &me() { return Object::me.as<State>(); }
const State &me() const { return Object::me.as<State>(); }
};
} // namespace cc