#include <iostream>
#include <assert.h>
#include <time.h>

#include "../include/Mole.h"
#include "../include/XmlRpc.h"
#include "../XmlRpcppServer.hpp"
#include "../methods/Homepage.hpp"

using namespace XmlRpc;
using namespace mole;

/**
 * Instances a xmlrpc server, binds some methods on it 
 * and then when for connection.
 */
int
main(int argc, char ** argv){
    if (argc != 2){
	std::cerr << "Usage : TestServer port\n";
	return EXIT_FAILURE;  
    }

    /* Creates a RPC Server */
    ctx::xmlrpcpp::XmlRpcppServer* rpcServer = new ctx::xmlrpcpp::XmlRpcppServer(atoi(argv[1]));

    /* Binds a method on it */
    XmlRpcServerMethod * method = new meth::Homepage(rpcServer->getRealServer());
    rpcServer->getRealServer()->addMethod(method);
    std::cout << "Waiting for connections.\n";
    rpcServer->start();

    return EXIT_SUCCESS;
}
