summaryrefslogtreecommitdiff
path: root/vdr-androvdr/select.h
blob: fbdeb027fabc7c2582cbded34fabfb3a4a633457 (plain)
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
/*
 * encapsulated poll
 */

#ifndef _VDRMON_SELECT
#define _VDRMON_SELECT

#include <string>
#include <sys/select.h>
#include "sock.h"
#include "handler.h"

struct node;
class cSelect
{
private:
  node * clientsockets;
  int clientsocketcount;
  cVdrmanagerServerSocket * serversocket;
  cHandler * handler;
  struct pollfd * pollfds;
  bool stopped;
  time_t nexttimer;
  time_t shutdown;
public:
  cSelect();
  virtual ~cSelect();
  void DispatchVdrEvent(string event);
  void SetServerSocket(cVdrmanagerServerSocket * sock);
  void AddClientSocket(cVdrmanagerClientSocket * sock);
  void RemoveClientSocket(cVdrmanagerClientSocket * sock);
  bool Action();
  bool Stop();
private:
  void CreatePollfds();
  cVdrmanagerClientSocket * GetClientSocket(int fd);
  bool Poll();
  void NotifyClients(string event);
};

#endif