MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / main

Function main

examples/send_receive.cpp:41–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39};
40
41int main(int argc, char** argv)
42{
43 MySender sender;
44
45 // Enable logging
46 sender.logging(true);
47
48 // Create and send a new order
49 proto::OrderMessage order({ proto::Order({ 1, "EURUSD", proto::OrderSide::buy, proto::OrderType::market, 1.23456, 1000.0 }) });
50 sender.send(order);
51
52 // Create and send a new balance wallet
53 proto::BalanceMessage balance({ proto::Balance({ "USD", 1000.0 }) });
54 sender.send(balance);
55
56 // Create and send a new account with some orders
57 proto::AccountMessage account({ proto::Account({ 1, "Test", proto::State::good, { "USD", 1000.0 }, std::make_optional<proto::Balance>({ "EUR", 100.0 }), {} }) });
58 account.body.orders.emplace_back(1, "EURUSD", proto::OrderSide::buy, proto::OrderType::market, 1.23456, 1000.0);
59 account.body.orders.emplace_back(2, "EURUSD", proto::OrderSide::sell, proto::OrderType::limit, 1.0, 100.0);
60 account.body.orders.emplace_back(3, "EURUSD", proto::OrderSide::buy, proto::OrderType::stop, 1.5, 10.0);
61 sender.send(account);
62
63 MyReceiver receiver;
64
65 // Enable logging
66 receiver.logging(true);
67
68 // Receive all data from the sender
69 receiver.receive(sender.buffer().data(), sender.buffer().size());
70
71 return 0;
72}

Callers

nothing calls this directly

Calls 10

emplace_backMethod · 0.80
OrderClass · 0.50
BalanceClass · 0.50
AccountClass · 0.50
loggingMethod · 0.45
sendMethod · 0.45
receiveMethod · 0.45
dataMethod · 0.45
bufferMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected