-
Notifications
You must be signed in to change notification settings - Fork 26
/
main.cpp
35 lines (30 loc) · 879 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include "SipServer.hpp"
#include "cxxopts.hpp"
int main(int argc, char** argv)
{
cxxopts::Options options("SipServer", "Open source server for handling voip calls based on sip.");
options.add_options()
("h,help", "Print usage")
("i,ip", "Sip server ip", cxxopts::value<std::string>())
("p,port", "Sip server ip.", cxxopts::value<int>()->default_value(std::to_string(5060)));
auto result = options.parse(argc, argv);
if (result.count("help"))
{
std::cout << options.help() << std::endl;
exit(0);
}
try
{
std::string ip = result["ip"].as<std::string>();
int port = result["port"].as<int>();
SipServer server(std::move(ip), port);
std::cout << "Server has been started. Listening..." << std::endl;
getchar();
}
catch (const cxxopts::OptionException&)
{
std::cout << "Please enter ip and port." << std::endl;
}
return 0;
}