ComsConnectAuthMessage.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #ifndef _ComsConnectAuthMessage_h
00022 #define _ComsConnectAuthMessage_h
00023 
00024 // The very first message sent from the client to the server
00025 // requesting a connection.
00026 //
00027 // Since version 37 the format of this message has been changed
00028 // it is now sent/serialized as a name/value pair list
00029 // this means we can add any extra args can be added without breaking
00030 // backward compatability
00031 
00032 #include <coms/ComsMessage.h>
00033 #include <stdlib.h>
00034 #include <map>
00035 #include <string>
00036 
00037 class ComsConnectAuthMessage : public ComsMessage
00038 {
00039 public:
00040         ComsConnectAuthMessage();
00041         virtual ~ComsConnectAuthMessage();
00042 
00043         void setUserName(const char *username) { setValue("username", username); }
00044         void setPassword(const char *password) { setValue("password", password); }
00045         void setUniqueId(const char *uid) { setValue("uid", uid); }
00046         void setSUI(const char *SUId) { setValue("SUId", SUId); }
00047         void setHostDesc(const char *host) { setValue("host", host); }
00048         void setCompatabilityVer(unsigned int settingsver);
00049         void setNoPlayers(unsigned int players);
00050 
00051         const char *getUserName() { return getValue("username"); }
00052         const char *getPassword() { return getValue("password"); }
00053         const char *getHostDesc() { return getValue("host"); }
00054         const char *getUniqueId() { return getValue("uid"); }
00055         const char *getSUI() { return getValue("SUId"); }
00056         unsigned int getNoPlayers() { 
00057                 return (unsigned int) atoi(getValue("numplayers")?getValue("numplayers"):"0"); }
00058         unsigned int getCompatabilityVer() { 
00059                 return (unsigned int) atoi(getValue("compatver")?getValue("compatver"):"0"); }
00060 
00061         // Inherited from ComsMessage
00062         virtual bool writeMessage(NetBuffer &buffer);
00063         virtual bool readMessage(NetBufferReader &reader);
00064 
00065 protected:
00066         std::map<std::string, std::string> values_;
00067 
00068         void setValue(const char *name, const char *value);
00069         const char *getValue(const char *name);
00070 
00071 private:
00072         ComsConnectAuthMessage(const ComsConnectAuthMessage &);
00073         const ComsConnectAuthMessage & operator=(const ComsConnectAuthMessage &);
00074 
00075 };
00076 
00077 #endif // _ComsConnectAuthMessage_h
00078 

Generated on Mon Feb 16 15:14:49 2009 for Scorched3D by  doxygen 1.5.3