RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
examples/standalone_bidder_ex.cc
00001 
00010 #include "rtbkit/plugins/exchange/http_exchange_connector.h"
00011 #include <boost/any.hpp>
00012 
00013 using namespace std;
00014 using namespace RTBKIT;
00015 
00016 
00017 
00018 struct DumpingExchangeConnector: public HttpExchangeConnector {
00019 
00020     DumpingExchangeConnector(const std::string & name,
00021                              std::shared_ptr<ServiceProxies> proxies)
00022         : HttpExchangeConnector(name, proxies)
00023     {
00024     }
00025 
00026     virtual std::string exchangeName() const
00027     {
00028         return "dumping";
00029     }
00030 
00031     virtual std::shared_ptr<BidRequest>
00032     parseBidRequest(HttpAuctionHandler & connection,
00033                     const HttpHeader & header,
00034                     const std::string & payload)
00035     {
00036         cerr << "got request" << endl << header << endl << payload << endl;
00037         return std::make_shared<BidRequest>();
00038     }
00039 
00040     virtual double
00041     getTimeAvailableMs(HttpAuctionHandler & connection,
00042                        const HttpHeader & header,
00043                        const std::string & payload)
00044     {
00045         return 10;
00046     }
00047 
00048     virtual double
00049     getRoundTripTimeMs(HttpAuctionHandler & connection,
00050                        const HttpHeader & header)
00051     {
00052         return 5;
00053     }
00054 
00055     virtual HttpResponse getResponse(const HttpAuctionHandler & connection,
00056                                      const HttpHeader & requestHeader,
00057                                      const Auction & auction) const
00058     {
00059         return HttpResponse(204, "", "");
00060     }
00061 
00062     virtual HttpResponse
00063     getDroppedAuctionResponse(const HttpAuctionHandler & connection,
00064                               const Auction & auction,
00065                               const std::string & reason) const
00066     {
00067         return HttpResponse(204, "application/json", "{}");
00068     }
00069 
00070     virtual HttpResponse
00071     getErrorResponse(const HttpAuctionHandler & connection,
00072                      const Auction & auction,
00073                      const std::string & errorMessage) const
00074     {
00075         return HttpResponse(400, "application/json", "{}");
00076     }
00077 };
00078 
00079 int main(int argc, char ** argv)
00080 {
00081     std::shared_ptr<ServiceProxies> proxies(new ServiceProxies());
00082 
00083     DumpingExchangeConnector connector("connector", proxies);
00084     
00085     connector.configureHttp(1, 10002, "0.0.0.0");
00086     connector.start();
00087     connector.enableUntil(Date::positiveInfinity());
00088 
00089     for (;;) {
00090         sleep(10.0);
00091     }
00092 
00093     return 1;
00094 }
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator