MakerLabs ACM
server_sent_events_emitter.h
Go to the documentation of this file.
1 /*
2  * Copyright Paul Reimer, 2018
3  *
4  * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 Unported License.
5  * To view a copy of this license, visit
6  * https://creativecommons.org/licenses/by-nc-sa/4.0/
7  * or send a letter to
8  * Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9  */
10 
11 #pragma once
12 
13 #include "delegate.hpp"
14 
15 #include "requests_generated.h"
16 
17 #include <experimental/string_view>
18 #include <string>
19 
20 namespace Requests {
21 
23 {
24 public:
26  using string = std::string;
27 
28  using PostCallbackAction = bool;
30  static constexpr PostCallbackAction AbortProcessing = false;
31  static constexpr PostCallbackAction ContinueProcessing = true;
32 
33  ServerSentEventsEmitter() = default;
34  ~ServerSentEventsEmitter() = default;
35 
36  auto parse(
37  const string_view chunk,
38  Callback&& _callback
39  ) -> bool;
40 
41 private:
42  string response_buffer;
43  string last_id;
44  bool first_chunk = true;
45 };
46 
47 } // namespace Requests
static constexpr PostCallbackAction ContinueProcessing
Definition: server_sent_events_emitter.h:31
std::experimental::string_view string_view
Definition: server_sent_events_emitter.h:25
std::string string
Definition: oom_killer_actor_behaviour.cpp:24
std::experimental::string_view string_view
Definition: actor_model.cpp:16
delegate< PostCallbackAction(string_view)> Callback
Definition: server_sent_events_emitter.h:29
auto parse(const string_view chunk, Callback &&_callback) -> bool
Definition: server_sent_events_emitter.cpp:26
Definition: server_sent_events_emitter.h:22
bool PostCallbackAction
Definition: server_sent_events_emitter.h:28
Definition: curl_library_info.cpp:15
static constexpr PostCallbackAction AbortProcessing
Definition: server_sent_events_emitter.h:30