00001 //********************************************************************** 00002 // 00003 // REGCOM: Regimental Command 00004 // Copyright (C) 2008 Randi J. Relander 00005 // <rjrelander@users.sourceforge.net> 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 3 00010 // of the License, or (at your option) any later version. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public 00018 // License along with this program. If not, see 00019 // <http://www.gnu.org/licenses/>. 00020 // 00021 //********************************************************************** 00022 00023 #ifndef REGCOM_SERVER_CONNECTION_H 00024 #define REGCOM_SERVER_CONNECTION_H 00025 00026 // SYSTEM INCLUDES 00027 #include <string> 00028 00029 // PROJECT INCLUDES 00030 #include "regcom/common/ErrorCode.h" 00031 #include "regcom/common/Player.h" 00032 #include "regcom/network/TcpSocket.h" 00033 #include "regcom/network/Message.h" 00034 #include "regcom/server/Server.h" 00035 #include "regcom/server/Database.h" 00036 00037 // NAMESPACES 00038 namespace regcom { 00039 namespace server { 00040 00042 // CLASS: Connection 00048 class Connection 00049 { 00050 public: 00051 00052 // PUBLIC METHODS 00053 00055 Connection(); 00056 00058 virtual ~Connection(); 00059 00061 common::ErrorCodeType Run( 00062 network::TcpSocket* pSocket, Database* pDatabase); 00063 00064 private: 00065 00066 // PRIVATE METHODS 00067 00069 static void ConnectionThread(Connection* pConnection); 00070 00072 void ProcessConnection(); 00073 00075 void ProcessCommand(const network::Message& rCommand); 00076 00078 void ProcessLoginCommand(const network::Message& rCommand); 00079 00080 // Sends message. 00081 void SendMessage(const std::string& rMessage); 00082 00083 // Sends connect message. 00084 void SendConnectMessage(); 00085 00086 // Sends error message. 00087 void SendErrorMessage( 00088 const std::string& rCommand, const std::string& rResult); 00089 00091 void LogMessage(const network::Message& rMessage); 00092 00094 void CreateEventMessage( 00095 const std::string& rType, network::Message& rMessage); 00096 00097 // MEMBER VARIABLES 00098 00100 network::TcpSocket* m_pSocket; 00101 00103 Database* m_pDatabase; 00104 00106 bool m_Connected; 00107 00109 int m_SessionState; 00110 00112 common::Player m_Player; 00113 00115 int m_ConnectionId; 00116 00118 static int m_ConnectionCount; 00119 }; 00120 00121 } // namespace server 00122 } // namespace regcom 00123 00124 #endif
Navigation
Home Page
Screen Shots
Developers
Documentation
Doxygen
Namespace List
Class List
Class Hierarchy
File List
Todo List
Links
SDL Library
License
SourceForge Project
Forums
Download
Regimental Command
Copyright © 2008
Randi J. Relander