1 |
// Decentralized Media |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include <menes/standard.hh> |
8 |
|
9 |
#include <menes-app/simple.hpp> |
10 |
#include <menes-etl/fnbind.hpp> |
11 |
#include <menes-net/http/request.hpp> |
12 |
#include <menes-net/http/response.hpp> |
13 |
|
14 |
#include "DecentralizedMedia.hpp" |
15 |
|
16 |
int Main(const app::Options& options) |
17 |
{ |
18 |
DecentralizedMedia media; |
19 |
|
20 |
media.Block(); |
21 |
|
22 |
return 0; |
23 |
} |
24 |
|
25 |
DecentralizedMedia::DecentralizedMedia() : waf::Server("Web"), process(bmp.IsRunning() ? NULL : new api::Process("/usr/X11R6/bin/beep-media-player")) |
26 |
{ |
27 |
AddPort(6996); |
28 |
} |
29 |
|
30 |
DecentralizedMedia::~DecentralizedMedia() |
31 |
{ |
32 |
if (!process.IsEmpty()) |
33 |
{ |
34 |
_H<api::Thread> thread(new api::Thread(etl::BindAll(&DecentralizedMedia::Destroy, this))); |
35 |
|
36 |
bmp.Quit(); |
37 |
|
38 |
thread->Join(); |
39 |
} |
40 |
} |
41 |
|
42 |
void DecentralizedMedia::Process(const net::Http::Request& request, net::Http::Response& response) |
43 |
{ |
44 |
if (request.method_ == "PLAY") |
45 |
api::Cout << "PLAY" << ios::NewLine; |
46 |
else if (request.method_ == "PAUSE") |
47 |
api::Cout << "PAUSE" << ios::NewLine; |
48 |
else |
49 |
waf::Server::Process(request, response); |
50 |
} |