1 #ifndef __BTANKS_SERVER_H__
2 #define __BTANKS_SERVER_H__
3 
4 /* Battle Tanks Game
5  * Copyright (C) 2006-2009 Battle Tanks team
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  */
21 
22 /*
23  * Additional rights can be granted beyond the GNU General Public License
24  * on the terms provided in the Exception. If you modify this file,
25  * you may extend this exception to your version of the file,
26  * but you are not obligated to do so. If you do not wish to provide this
27  * exception without modification, you must delete this exception statement
28  * from your version and license this file solely under the GPL without exception.
29 */
30 
31 
32 #include "mrt/tcp_socket.h"
33 #include "mrt/udp_socket.h"
34 
35 class PlayerState;
36 class Message;
37 class Monitor;
38 
39 class Server {
40 public:
41 	Server();
42 	void init();
43 	void send(const int id, const Message &m);
44 	void broadcast(const Message &m);
45 	void tick(const float dt);
46 	~Server();
47 
48 	const bool active() const;
49 	void disconnect(const int id);
50 
51 	void restart();
52 	void disconnect_all();
53 
54 private:
55 	Server(const Server &);
56 	const Server& operator=(const Server &);
57 	Monitor *_monitor;
58 
59 	mrt::TCPSocket _sock;
60 	mrt::UDPSocket _udp_sock;
61 };
62 
63 
64 #endif
65 
66