4 // A Client represents a single connection from a client (watching a single stream).
13 // Digested statistics for writing to logs etc.
14 // Note that "referer" and "user_agent" here are already escaped for scary characters.
18 std::string remote_addr;
20 std::string user_agent;
21 timespec connect_time;
24 size_t num_loss_events;
30 // Serialization/deserialization.
31 Client(const ClientProto &serialized, Stream *stream);
32 ClientProto serialize() const;
34 ClientStats get_stats() const;
36 // The file descriptor associated with this socket.
39 // When the client connected, in terms of CLOCK_MONOTONIC_COARSE.
40 timespec connect_time;
42 // Some information only used for logging.
43 std::string remote_addr;
45 std::string user_agent;
47 enum State { READING_REQUEST, SENDING_HEADER, SENDING_DATA, SENDING_ERROR, WAITING_FOR_KEYFRAME, PREBUFFERING };
50 // The HTTP request, as sent by the client. If we are in READING_REQUEST,
51 // this might not be finished.
54 // What stream we're connecting to; parsed from <request>.
55 // Not relevant for READING_REQUEST.
59 // The header we want to send. This is nominally a copy of Stream::header,
60 // but since that might change on reconnects etc., we keep a local copy here.
61 // Only relevant for SENDING_HEADER or SENDING_ERROR; blank otherwise.
62 std::string header_or_error;
64 // Number of bytes we've sent of the header. Only relevant for SENDING_HEADER
66 size_t header_or_error_bytes_sent;
68 // Number of bytes we are into the stream (ie., the end of last send).
69 // -1 means we want to send from the end of the backlog (the normal case),
70 // although only at a keyframe.
71 // -2 means we want to send from the _beginning_ of the backlog.
72 // Once we go into WAITING_FOR_KEYFRAME, PREBUFFERING or SENDING_DATA,
73 // these negative values will be translated to real numbers.
76 // Number of bytes we've sent of data. Only relevant for SENDING_DATA.
79 // Number of times we've skipped forward due to the backlog being too big,
80 // and how many bytes we've skipped over in all. Only relevant for SENDING_DATA.
81 size_t bytes_lost, num_loss_events;
84 #endif // !defined(_CLIENT_H)