/* 
 * File:   main.cpp
 * Author: pgess
 *
 * Created on March 28, 2016, 3:59 PM
 */

#include "XreateServer.h"

#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
#include <thrift/protocol/TJSONProtocol.h>
#include <thrift/server/TThreadPoolServer.h>
#include <thrift/server/TThreadedServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/THttpServer.h>
#include <thrift/transport/TTransportUtils.h>
#include <thrift/TToString.h>

#include <boost/make_shared.hpp>

#include <iostream>
#include <stdexcept>
#include <sstream>

using namespace std;
using namespace apache::thrift;
using namespace apache::thrift::concurrency;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace apache::thrift::server;

int main() {
  TThreadedServer server(
  
  //Processor:
    boost::make_shared<AbstractXreateServerProcessorFactory>(boost::make_shared<XreateServerFactory>()),
          
  //serverSocket:
    boost::shared_ptr<TServerSocket>(new TServerSocket(9090)),
  
  //transportFactory
    boost::shared_ptr<TTransportFactory>(new THttpServerTransportFactory()),
         
  //protocolFactory
    boost::shared_ptr<TProtocolFactory>(new TJSONProtocolFactory())
  );
  
  /*
   * new TThreadPoolServer(,
                                       serverSocket,
                                       transportFactory,
                                       ,
                                       threadManager)
   */

  cout << "Starting the server..." << endl;
  server.serve();
  cout << "Done." << endl;
  return 0;
}