]> git.tdb.fi Git - xinema.git/blob - source/networkinterface.h
Create an icon for the remote
[xinema.git] / source / networkinterface.h
1 #ifndef NETWORKINTERFACE_H_
2 #define NETWORKINTERFACE_H_
3
4 #include <msp/core/thread.h>
5 #include <msp/io/eventdispatcher.h>
6 #include <msp/io/pipe.h>
7 #include <msp/net/datagramsocket.h>
8 #include <msp/net/streamserversocket.h>
9
10 class Client;
11 class Xinema;
12
13 class NetworkInterface
14 {
15 private:
16         class NetworkThread: public Msp::Thread
17         {
18         private:
19                 NetworkInterface &network;
20                 Msp::IO::Pipe wakeup_pipe;
21                 bool done;
22
23         public:
24                 NetworkThread(NetworkInterface &);
25
26                 void terminate();
27
28         private:
29                 virtual void main();
30         };
31
32         Xinema &xinema;
33         Msp::Net::StreamServerSocket *server_sock;
34         Msp::Net::DatagramSocket *discover_sock;
35         Msp::IO::EventDispatcher event_disp;
36         NetworkThread *thread;
37         std::list<Client *> clients;
38
39 public:
40         NetworkInterface(Xinema &);
41         ~NetworkInterface();
42
43 private:
44         void connection_available();
45         void discover_request();
46 };
47
48 #endif