![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 /* 00002 * SraNtetworkShared - Some shared stuff that is used by all network related classes. 00003 * 00004 * @Author Michael Matzen 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License as published by the Free 00008 * Software Foundation; either version 2 of the License, or (at your option) 00009 * any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but WITHOUT 00012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00014 * more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along with 00017 * this program; if not, write to the Free Software Foundation, Inc., 51 00018 * Franklin St, Fifth Floor, Boston, MA 02110, USA 00019 * 00020 */ 00021 #ifndef __SRANETWORK_SOCKET 00022 #define __SRANETWORK_SOCKET 00023 00024 //RakNet 00025 #include "RakPeerInterface.h" 00026 #include "BitStream.h" 00027 #include "MessageIdentifiers.h" 00028 00029 namespace SraNetwork { 00030 00031 // The default ports 00032 // The naming is : SOURCE_TARGET_PORT 00033 // So SERVER_CLIENT means: The port is used for the socket on the server 00034 // and a client is connecting to this port. 00035 00036 // SERVER SIDE 00037 static const unsigned short SERVER_CLIENT_PORT = 12000; //Port for connecting clients and server 00038 static const unsigned short SERVER_ZONE_PORT = 12001; //Port for connecting zones and server 00039 static const unsigned short SERVER_CHAT_PORT = 12002; //Port for connecting chat and world server 00040 static const unsigned short CHAT_CLIENT_PORT = 12003; //Port for connecting clients and the chat server 00041 00042 static const unsigned short CHAT_SERVER_PORT = 12004; //Default chat server port 00043 static const unsigned short ZONE_SERVER_PORT = 12005; //Default zone server port 00044 00045 // CLIENT SIDE 00046 static const unsigned short CLIENT_SERVER_PORT = 12006; //Default client port 00047 static const unsigned short CLIENT_CHAT_PORT = 12007; //Default client port 00048 00049 00050 static const unsigned short MAX_CLIENTS = 50; //Maximum number of clients 00051 00052 static const unsigned short PACKAGE_SIZE = 1024; //Size of one package 00053 static const unsigned short PACKAGE_DATA_SIZE = PACKAGE_SIZE - sizeof(char) - sizeof(int); //package_size - opcode - pID 00054 00055 static const int KEEPALIVE_TIMEOUT = 60; //sec 00056 00057 // Max size of a single string. 00058 static const int MAX_STRLEN = 256; 00059 00060 //Address of the world server, because currently the processes are 00061 //running on the same machine, we can use localhost. 00062 static const char* WORLD_SERVER_ADDR = "127.0.0.1"; 00063 00064 //Zone server adress that is returned to the client. 00065 //TODO: We really have to get the systems public ip :P 00066 static const char* ZONE_SERVER_ADDR = "127.0.0.1"; 00067 00068 //Chat server adress that is returned to the client. 00069 //TODO: We really have to get the systems public ip :P 00070 static const char* CHAT_SERVER_ADDR = "127.0.0.1"; 00071 00077 struct SraPacket2 { 00078 unsigned char opcode; //SraMessageIdentifiers 00079 int pID; 00080 wchar_t data[PACKAGE_DATA_SIZE]; 00081 }; 00082 00094 struct SraZonePacket { 00095 int clientID; 00096 int fromZoneID; 00097 int toZoneID; 00098 }; 00099 00100 00101 //A small struct to store client stuff 00102 struct SraClientData 00103 { 00104 int clientID; 00105 int zoneID; 00106 __int64 lastKeepAlive; 00107 bool operator==( const SraClientData& right ) const 00108 { 00109 return right.clientID == clientID && right.lastKeepAlive == lastKeepAlive; 00110 } 00111 }; 00112 00117 enum SraMessageIdentifiers 00118 { 00119 ID_LOGIN_REQ = ID_USER_PACKET_ENUM, 00120 ID_LOGIN_REP, 00121 ID_QUIT, 00122 ID_GET_SRVLIST, 00123 ID_CONNECT_TO_SRV, 00124 ID_GET_CLIENT_CHARS, 00125 ID_CREATE_CHAR, 00126 ID_CREATE_CHAR_REP, 00127 ID_CHAT_CHANNEL_MESSAGE, 00128 ID_CHAT_MSG_REQUEST_PENDING, 00129 ID_CHAT_CHANNEL_REGISTER, 00130 ID_CHAT_CHANNEL_UNREGISTER, 00131 ID_IAM_ALIVE, 00132 ID_SRA_REPLY, 00133 }; 00134 00135 } 00136 #endif
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.