<commit_before>/** mock_adserver_connector.cc                                 -*- C++ -*-
    <NAME>, 03 April 2013
    Copyright (c) 2013 Datacratic.  All rights reserved.

    Example of a simple ad server connector.

*/

#include "mock_adserver_connector.h"
#include "soa/service/service_base.h"
#include "soa/service/service_utils.h"
#include "rtbkit/common/analytics.h"

using namespace RTBKIT;

MockAdServerConnector::
MockAdServerConnector(std::string const & serviceName,
                      std::shared_ptr<ServiceProxies> const & proxies,
                      const Json::Value & json) :
    HttpAdServerConnector(serviceName, proxies)
{
    if (json != Json::Value::null) {
        int winPort = json.get("winPort", "12340").asInt();
        int eventPort = json.get("eventPort", "12341").asInt();
        init(winPort, eventPort);
    }
}

MockAdServerConnector::
MockAdServerConnector(Datacratic::ServiceProxyArguments & args,
                      const std::string& serviceName) :
    HttpAdServerConnector(serviceName, args.makeServiceProxies())
{}

MockAdServerConnector::~MockAdServerConnector(){}

void MockAdServerConnector::init(int winPort, int eventPort) {
    auto services = getServices();

    // Initialize our base class
    HttpAdServerConnector::init(services->config);

    // Prepare a simple JSON handler that already parsed the incoming HTTP payload so that it can
    // create the requied post bidRequest object.
    auto handleEvent = [&](const Datacratic::HttpHeader & header,
                           const Json::Value & json,
                           const std::string & text) {
        return this->handleEvent(PostAuctionEvent(json));
    };
    registerEndpoint(winPort, handleEvent);
    registerEndpoint(eventPort, handleEvent);

    // Publish the endpoint now that it exists.
    HttpAdServerConnector::bindTcp();
    <commit_msg>fix mock adserver condition<commit_after>/** mock_adserver_connector.cc                                 -*- C++ -*-
    <NAME>, 03 April 2013
    Copyright (c) 2013 Datacratic.  All rights reserved.

    Example of a simple ad server connector.

*/

#include "mock_adserver_connector.h"
#include "soa/service/service_base.h"
#include "soa/service/service_utils.h"
#include "rtbkit/common/analytics.h"

using namespace RTBKIT;

MockAdServerConnector::
MockAdServerConnector(std::string const & serviceName,
                      std::shared_ptr<ServiceProxies> const & proxies,
                      const Json::Value & json) :
    HttpAdServerConnector(serviceName, proxies)
{
    int winPort = json.get("winPort", "12340").asInt();
    int eventPort = json.get("eventPort", "12341").asInt();
    init(winPort, eventPort);
}

MockAdServerConnector::
MockAdServerConnector(Datacratic::ServiceProxyArguments & args,
                      const std::string& serviceName) :
    HttpAdServerConnector(serviceName, args.makeServiceProxies())
{}

MockAdServerConnector::~MockAdServerConnector(){}

void MockAdServerConnector::init(int winPort, int eventPort) {
    auto services = getServices();

    // Initialize our base class
    HttpAdServerConnector::init(services->config);

    // Prepare a simple JSON handler that already parsed the incoming HTTP payload so that it can
    // create the requied post bidRequest object.
    auto handleEvent = [&](const Datacratic::HttpHeader & header,
                           const Json::Value & json,
                           const std::string & text) {
        return this->handleEvent(PostAuctionEvent(json));
    };
    registerEndpoint(winPort, handleEvent);
    registerEndpoint(eventPort, handleEvent);

    // Publish the endpoint now that it exists.
    HttpAdServerConnector::bindTcp();
    
{'fraction_non_alphanumeric': 0.10732492621411323, 'fraction_numerical': 0.010732492621411323, 'mean_word_length': 3.1147902869757176, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '929328', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1040, 'n_words': 252}