-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.cpp
More file actions
47 lines (37 loc) · 965 Bytes
/
Copy pathapp.cpp
File metadata and controls
47 lines (37 loc) · 965 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
47
#include "app.h"
#include "log.h"
#include "vpException.h"
App::App()
{
}
bool App::start(const std::string &ip, int port)
{
try
{
m_httpServer.setRequestCallback(std::bind(&App::newRequest, this,
std::placeholders::_1,
std::placeholders::_2));
if (!m_httpServer.startListing(ip, port))
return false;
}
catch (const ReaderError &exc)
{
PRINT_ERROR("! Exception. " << exc.what());
}
catch (...)
{
PRINT_ERROR("! Unknown exception. ");
}
return true;
}
bool App::stop()
{
return m_httpServer.stop();
}
bool App::newRequest(const std::string &filename, float gain)
{
auto resultFuture = m_processor.addTask(filename, gain);
if (resultFuture.wait_for(std::chrono::seconds(5)) == std::future_status::timeout)
return false;
return resultFuture.get();
}