summaryrefslogtreecommitdiffstats
path: root/source/cWebAdmin.h
blob: da60a5492cd770b903429c1de4d3585bbdad239d (plain) (blame)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once

#include "../WebServer/WebServer.h"
#include "cSocket.h"

class cStringMap;
//tolua_begin
struct HTTPRequest
{
	std::string Method;
	std::string Path;
	cStringMap* Params;
	cStringMap* PostParams;
	std::string Username;
};
//tolua_end

struct lua_State;
class cEvent;
class cIniFile;
class cWebPlugin;
class cWebAdmin
{
public:
	cWebAdmin( int a_Port = 8080 );
	~cWebAdmin();

	bool Init( int a_Port );

	void AddPlugin( cWebPlugin* a_Plugin );
	void RemovePlugin( cWebPlugin* a_Plugin );

	typedef std::list< cWebPlugin* > PluginList;
	PluginList GetPlugins() { return m_Plugins; }

	static void Request_Handler(webserver::http_request* r);

	void RemovePlugin( lua_State* L );
private:

#ifdef _WIN32
	static DWORD WINAPI ListenThread(LPVOID lpParam);
#else
	static void *ListenThread( void *lpParam );
#endif

	std::string GetTemplate();

	int m_Port;

	bool m_bConnected;
	cSocket m_ListenSocket;

	cIniFile* m_IniFile;
	PluginList m_Plugins;

	cEvent* m_Event;

	webserver* m_WebServer;
};