#include <iostream>

#include <stdio.h>
#include "logger.hpp"
#include "plugin_config.hpp"
#include "options.hpp"
#include "sctp_server.hpp"
#include "plugin_app.hpp"
#include "plugin_server.hpp"


using namespace std;
using namespace config;
using namespace sctp;
using namespace amf_application;
plugin_config plugin_cfg;
plugin_app plugin_app_inst;
sctp_server * sctp_s_38412 = nullptr;

std::string amf_ip;
unsigned int amf_port;



int main(int argc, char **argv)
{
     if (!Options::parse(argc, argv)) {
        std::cout << "Options::parse() failed" << std::endl;
        return 1;
    }
    Logger::init("plugin", Options::getlogStdout(), Options::getlogRotFilelog());
    Logger::plugin_app().startup("Options parsed!");
    if(plugin_cfg.load(Options::getlibconfigConfig()) < 0) return 0;
         plugin_cfg.display();


    sctp_s_38412 = new sctp_server(plugin_cfg.n2.addr4.c_str(), plugin_cfg.n2.port);
    Logger::sctp().info(
      "Set N2 AMF IPv4 Addr, port: %s, %d", plugin_cfg.n2.addr4.c_str(), plugin_cfg.n2.port);

    sctp_s_38412->start_receive(sctp_s_38412);

    Pistache::Address addr(plugin_cfg.sbi.addr4, Pistache::Port(plugin_cfg.sbi.port));
    PLUGINApiServer pluginApiServer(addr);
    pluginApiServer.init(PISTACHE_SERVER_THREADS);
    std::thread plugin_api_manager(&PLUGINApiServer::start, pluginApiServer);



/*开机首先向NRF请求AMF地址，开启sctp接收，AMF地址为全局变量（方便用）




/*  需要等NRF共能完善
/*订阅AMF状态*/
/*接收http*/
    /*amf消息*/
    /*nrf消息*/
     pause();

    return 0;
}
