Skip to content

Commit

Permalink
Update to the latest oatpp API.
Browse files Browse the repository at this point in the history
  • Loading branch information
lganzzzo committed May 23, 2020
1 parent 49b746f commit d144568
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions client-binance.com/src/AggregateTradesListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
/**
* Listener for Aggregate Trade events
*/
class AggregateTradesListener : public WSEventListener<AggregateTrade> {
class AggregateTradesListener : public WSEventListener<oatpp::Object<AggregateTrade>> {
public:

AggregateTradesListener(const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& mapper)
: WSEventListener<AggregateTrade>(mapper)
: WSEventListener<oatpp::Object<AggregateTrade>>(mapper)
{}

void onEvent(const AggregateTrade::ObjectWrapper& trade) override {
void onEvent(const oatpp::Object<AggregateTrade>& trade) override {

OATPP_LOGI("AggregateTrades", "%s - quantity=%s, price=%s, time=%d / firstTradeId=%d, lastTradeId=%d",
trade->symbol->c_str(),
Expand Down
6 changes: 3 additions & 3 deletions client-binance.com/src/KlineCandlestickListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
/**
* Listener for Trade events
*/
class KlineCandlestickListener : public WSEventListener<Candlestick> {
class KlineCandlestickListener : public WSEventListener<oatpp::Object<Candlestick>> {
public:

KlineCandlestickListener(const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& mapper)
: WSEventListener<Candlestick>(mapper)
: WSEventListener<oatpp::Object<Candlestick>>(mapper)
{}

void onEvent(const Candlestick::ObjectWrapper& obj) override {
void onEvent(const oatpp::Object<Candlestick>& obj) override {

OATPP_LOGI("Kline/Candlesticks", "%s - startTime=%d, closeTime=%d / openPrice=%s, closePrice=%s, highPrice=%s, lowPrice=%s",
obj->symbol->c_str(),
Expand Down
18 changes: 9 additions & 9 deletions client-binance.com/src/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* DTO representing "Aggregate Trade Stream" object from binance-exchange.
* See https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#aggregate-trade-streams
*/
class AggregateTrade : public oatpp::Object {
class AggregateTrade : public oatpp::DTO {

DTO_INIT(AggregateTrade, Object)
DTO_INIT(AggregateTrade, DTO)

DTO_FIELD(String, eventType, "e");
DTO_FIELD(Int64, eventTime, "E");
Expand All @@ -33,9 +33,9 @@ class AggregateTrade : public oatpp::Object {
* DTO representing "Trade Stream" object from binance-exchange.
* See https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#trade-streams
*/
class Trade : public oatpp::Object {
class Trade : public oatpp::DTO {

DTO_INIT(Trade, Object)
DTO_INIT(Trade, DTO)

DTO_FIELD(String, eventType, "e");
DTO_FIELD(Int64, eventTime, "E");
Expand All @@ -54,9 +54,9 @@ class Trade : public oatpp::Object {
/**
* Nested object for Candlestick
*/
class Kline : public oatpp::Object {
class Kline : public oatpp::DTO {

DTO_INIT(Kline, Object)
DTO_INIT(Kline, DTO)

DTO_FIELD(Int64, klineStartTime, "t");
DTO_FIELD(Int64, klineCloseTime, "T");
Expand Down Expand Up @@ -86,14 +86,14 @@ class Kline : public oatpp::Object {
* DTO representing "Kline/Candlestick Stream" object from binance-exchange.
* See https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#klinecandlestick-streams
*/
class Candlestick : public oatpp::Object {
class Candlestick : public oatpp::DTO {

DTO_INIT(Candlestick, Object)
DTO_INIT(Candlestick, DTO)

DTO_FIELD(String, eventType, "e");
DTO_FIELD(Int64, eventTime, "E");
DTO_FIELD(String, symbol, "s");
DTO_FIELD(Kline::ObjectWrapper, kline, "k");
DTO_FIELD(Object<Kline>, kline, "k");

};

Expand Down
6 changes: 3 additions & 3 deletions client-binance.com/src/TradesListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
/**
* Listener for Trade events
*/
class TradesListener : public WSEventListener<Trade> {
class TradesListener : public WSEventListener<oatpp::Object<Trade>> {
public:

TradesListener(const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& mapper)
: WSEventListener<Trade>(mapper)
: WSEventListener<oatpp::Object<Trade>>(mapper)
{}

void onEvent(const Trade::ObjectWrapper& trade) override {
void onEvent(const oatpp::Object<Trade>& trade) override {

OATPP_LOGI("Trades", "%s - quantity=%s, price=%s, time=%d",
trade->symbol->c_str(),
Expand Down
2 changes: 1 addition & 1 deletion client-binance.com/src/WSEventListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WSEventListener : public WSListener {
onEvent(eventObject);
}

virtual void onEvent(const typename T::ObjectWrapper& eventObject) = 0;
virtual void onEvent(const T& eventObject) = 0;

};

Expand Down

0 comments on commit d144568

Please sign in to comment.