ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/DecentralizedMedia/DecentralizedMedia.cpp
(Generate patch)

Comparing DecentralizedMedia/DecentralizedMedia.cpp (file contents):
Revision 470 by douglas, 2005-06-07T20:45:08-07:00 vs.
Revision 471 by douglas, 2005-06-07T23:33:55-07:00

# Line 6 | Line 6
6  
7   #include <menes/standard.hh>
8  
9 < #include <menes-waf/server.hpp>
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 "BeepRemote.hpp"
14 > #include "DecentralizedMedia.hpp"
15  
16 < class DecentralizedMedia : public waf::Server
16 > int Main(const app::Options& options)
17   {
18 < public:
16 <        BeepRemote bmp;
17 < private:
18 <        _H<api::Thread> block;
19 <        _H<api::Process> process;
20 <        int Destroy() { return process->Join(); }
21 < protected:
22 <        virtual void Process(const net::Http::Request& request, net::Http::Response& response)
23 <        {
24 <                if (request.method_ == "PLAY")
25 <                        api::Cout << "PLAY" << ios::NewLine;
26 <                else if (request.method_ == "PAUSE")
27 <                        api::Cout << "PAUSE" << ios::NewLine;
28 <                else
29 <                        waf::Server::Process(request, response);
30 <        }
31 < public:
32 <        // XXX: "../Web" can be "Web" when we take out the evil juju
33 <        DecentralizedMedia() : waf::Server("../Web"), process(bmp.IsRunning() ? NULL : new api::Process("/usr/X11R6/bin/beep-media-player"))
34 <        {
35 <                AddPort(6996);
36 <        }
37 <        ~DecentralizedMedia()
38 <        {
39 <                if (!process.IsEmpty())
40 <                {
41 <                        _H<api::Thread> thread(new api::Thread(etl::BindAll(&DecentralizedMedia::Destroy, this)));
18 >        DecentralizedMedia media;
19  
20 <                        bmp.Quit();
20 >        return 0;
21 > }
22  
23 <                        thread->Join();
24 <                }
25 <        }
26 < };
23 > DecentralizedMedia::DecentralizedMedia() : waf::Server("Web"), process(bmp.IsRunning() ? NULL : new api::Process("/usr/X11R6/bin/beep-media-player"))
24 > {
25 >        AddPort(6996);
26 > }
27  
28 < int Main(const app::Options& options)
28 > DecentralizedMedia::~DecentralizedMedia()
29   {
30 <        // XXX: evil juju to make waf::Server behave nicely
31 <        ::chdir("menes");
30 >        if (!process.IsEmpty())
31 >        {
32 >                _H<api::Thread> thread(new api::Thread(etl::BindAll(&DecentralizedMedia::Destroy, this)));
33  
34 <        DecentralizedMedia media;
34 >                bmp.Quit();
35  
36 <        return 0;
36 >                thread->Join();
37 >        }
38 > }
39 >
40 > void DecentralizedMedia::Process(const net::Http::Request& request, net::Http::Response& response)
41 > {
42 >        if (request.method_ == "PLAY")
43 >                api::Cout << "PLAY" << ios::NewLine;
44 >        else if (request.method_ == "PAUSE")
45 >                api::Cout << "PAUSE" << ios::NewLine;
46 >        else
47 >                waf::Server::Process(request, response);
48   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines