This example can be found in Development\restserver\restserver.cpp.
This example shows how to enable the REST server using the PST SDK. The REST server enables network-based access to the PST Tracker using the HTTP protocol. GET and POST requests can be made to the server to send and receive data and change parameters. The REST interface offers a programming language independent interface to the PST Trsacker. Besides accessing the REST server directly using a browser, a networking library like Curl can be used to interface with the server programatically.
#ifdef WIN32
#include <windows.h>
#endif
static void Exithandler(int sig);
#ifdef WIN32
BOOL WINAPI ConsoleHandler(DWORD CEvent)
{
Exithandler(CEvent);
return TRUE;
}
#endif
#include <memory>
#include <iostream>
std::shared_ptr<PSTech::pstsdk::Tracker> pst;
static void Exithandler(int sig)
{
pst->Shutdown();
}
int main(int argc, char *argv[])
{
#ifdef WIN32
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
#else
signal(SIGTERM, Exithandler);
signal(SIGKILL, Exithandler);
signal(SIGQUIT, Exithandler);
signal(SIGINT, Exithandler);
#endif
try
{
pst = std::make_shared<PSTech::pstsdk::Tracker>();
pst->Start();
pst->EnableRestServer("localhost", "7278");
Sleep(60000);
pst->DisableRestServer();
}
{
}
pst->Shutdown();
return 0;
}