changed: update version strings for beta4
[xbmc.git] / xbmc / utils / EventServer.h
blob4a42cc6f0478e25fffa0d98cc9ceed7853bc753e
1 #ifndef __EVENT_SERVER_H__
2 #define __EVENT_SERVER_H__
4 /*
5 * Copyright (C) 2005-2008 Team XBMC
6 * http://www.xbmc.org
8 * This Program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
13 * This Program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with XBMC; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 * http://www.gnu.org/copyleft/gpl.html
25 #include "Thread.h"
26 #include "Socket.h"
27 #include "EventClient.h"
28 #include "CriticalSection.h"
29 #include "SingleLock.h"
31 #include <map>
32 #include <queue>
33 #include <vector>
35 namespace EVENTSERVER
38 /**********************************************************************/
39 /* UDP Event Server Class */
40 /**********************************************************************/
41 class CEventServer : private CThread
43 public:
44 static void RemoveInstance();
45 static CEventServer* GetInstance();
46 virtual ~CEventServer() {}
48 // IRunnable entry point for thread
49 virtual void Process();
51 bool Running()
53 return m_bRunning;
56 void RefreshSettings()
58 CSingleLock lock(m_critSection);
59 m_bRefreshSettings = true;
62 // start / stop server
63 void StartServer();
64 void StopServer(bool bWait);
66 // get events
67 unsigned short GetButtonCode(std::string& strMapName, bool& isAxis, float& amount);
68 bool ExecuteNextAction();
69 bool GetMousePos(float &x, float &y);
70 int GetNumberOfClients();
72 protected:
73 CEventServer();
74 void Cleanup();
75 void Run();
76 void ProcessPacket(SOCKETS::CAddress& addr, int packetSize);
77 void ProcessEvents();
78 void RefreshClients();
80 std::map<unsigned long, EVENTCLIENT::CEventClient*> m_clients;
81 static CEventServer* m_pInstance;
82 SOCKETS::CUDPSocket* m_pSocket;
83 int m_iPort;
84 int m_iListenTimeout;
85 int m_iMaxClients;
86 unsigned char* m_pPacketBuffer;
87 bool m_bRunning;
88 CCriticalSection m_critSection;
89 bool m_bRefreshSettings;
94 #endif // __EVENT_SERVER_H__