Joel Grunbaum
2022-01-20 128c6d51ec8c70e230dc86b100cb887ba3f0378d
commit | author | age
16b655 1 #pragma once
JG 2
3 #include "book.hpp"
4 #include "json.hpp"
5
0b7aa0 6 #include <deque>
16b655 7 #include <string>
JG 8 #include <unordered_map>
9
10 namespace protocol
11 {
12 enum OrderEnum { ADD, DELETE, BROKER_REQUEST, BROKER_CONFIRM };
13
6926be 14 // Catchup utilities
16b655 15 std::unordered_map<std::string, book::Book> recoverBook();
0b7aa0 16 void createWebSocket();
JG 17 std::deque<json::Message*>
18 catchUp(std::unordered_map<std::string, book::Book>& bs);
16b655 19
6926be 20 // Outgoing messages
JG 21 json::Message* addOrder(json::AddMessage& order);
22 json::Message* deleteOrder(json::DeleteMessage& order);
16b655 23
JG 24 // Incoming messages
25 void handleMessage(std::unordered_map<std::string, book::Book>& bs,
26                    json::Message* message);
27 void announce(std::unordered_map<std::string, book::Book>& bs,
28               json::AnnounceMessage* message);
29 void settle(std::unordered_map<std::string, book::Book>& bs,
30             json::SettleMessage* message);
31 void addedOrder(std::unordered_map<std::string, book::Book>& bs,
6926be 32                 json::AddedMessage* message);
16b655 33 void deletedOrder(std::unordered_map<std::string, book::Book>& bs,
6926be 34                   json::DeletedMessage* message);
16b655 35 void tradeOrder(std::unordered_map<std::string, book::Book>& bs,
JG 36                 json::TradeMessage* message);
37 void broker(std::unordered_map<std::string, book::Book>& bs,
38             json::Broker* message);
39
6926be 40 json::Message* send(std::string& message);
16b655 41 } // namespace protocol