1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D is free software; you can redistribute it and/or modify
7 //    it under the terms of the GNU General Public License as published by
8 //    the Free Software Foundation; either version 2 of the License, or
9 //    (at your option) any later version.
10 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #ifndef _comsConnectMessage_h
22 #define _comsConnectMessage_h
23 
24 // The very first message sent from the client to the server
25 // requesting a connection.
26 //
27 // Since version 37 the format of this message has been changed
28 // it is now sent/serialized as a name/value pair list
29 // this means we can add any extra args can be added without breaking
30 // backward compatability
31 
32 #include <coms/ComsMessage.h>
33 #include <stdlib.h>
34 #include <map>
35 #include <string>
36 
37 class ComsConnectMessage : public ComsMessage
38 {
39 public:
40 	static ComsMessageType ComsConnectMessageType;
41 
42 	ComsConnectMessage();
43 	virtual ~ComsConnectMessage();
44 
setVersion(const char * version)45 	void setVersion(const char *version) { setValue("version", version); }
setProtocolVersion(const char * pversion)46 	void setProtocolVersion(const char *pversion) { setValue("pversion", pversion); }
47 
getVersion()48 	const char *getVersion() { return getValue("version"); }
getProtocolVersion()49 	const char *getProtocolVersion() { return getValue("pversion"); }
50 
51 	// Inherited from ComsMessage
52 	virtual bool writeMessage(NetBuffer &buffer);
53 	virtual bool readMessage(NetBufferReader &reader);
54 
55 protected:
56 	std::map<std::string, std::string> values_;
57 
58 	void setValue(const char *name, const char *value);
59 	const char *getValue(const char *name);
60 
61 private:
62 	ComsConnectMessage(const ComsConnectMessage &);
63 	const ComsConnectMessage & operator=(const ComsConnectMessage &);
64 
65 };
66 
67 #endif // _comsConnectMessage_h
68 
69