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