Cleaned up web interface server, starting work on getting tcp connections to persist then will hook it up to the websockets/http/whatever else we deem worthy.

This commit is contained in:
KimLS
2014-07-07 22:19:46 -07:00
parent 74f07f8e19
commit 9e3e8dbfa6
20 changed files with 158 additions and 634 deletions
+40
View File
@@ -0,0 +1,40 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(web_interface_sources
web_interface.cpp
worldserver.cpp
)
SET(web_interface_headers
worldserver.h
)
ADD_EXECUTABLE(web_interface ${web_interface_sources} ${web_interface_headers})
INSTALL(TARGETS web_interface RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
ADD_DEFINITIONS(-DQSERV)
TARGET_LINK_LIBRARIES(web_interface Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC)
SET_TARGET_PROPERTIES(web_interface PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
TARGET_LINK_LIBRARIES(web_interface "Ws2_32.lib")
ENDIF(MSVC)
IF(MINGW)
TARGET_LINK_LIBRARIES(web_interface "WS2_32")
ENDIF(MINGW)
IF(UNIX)
TARGET_LINK_LIBRARIES(web_interface "${CMAKE_DL_LIBS}")
TARGET_LINK_LIBRARIES(web_interface "z")
TARGET_LINK_LIBRARIES(web_interface "m")
IF(NOT DARWIN)
TARGET_LINK_LIBRARIES(web_interface "rt")
ENDIF(NOT DARWIN)
TARGET_LINK_LIBRARIES(web_interface "pthread")
ADD_DEFINITIONS(-fPIC)
ENDIF(UNIX)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/Bin)
+55
View File
@@ -0,0 +1,55 @@
#include "../common/debug.h"
#include "../common/opcodemgr.h"
#include "../common/EQStreamFactory.h"
#include "../common/rulesys.h"
#include "../common/servertalk.h"
#include "../common/platform.h"
#include "../common/crash.h"
#include "../common/EQEmuConfig.h"
#include "worldserver.h"
#include <signal.h>
volatile bool run = true;
TimeoutManager timeout_manager;
const EQEmuConfig *config = nullptr;
WorldServer *worldserver = nullptr;
void CatchSignal(int sig_num) {
run = false;
if(worldserver)
worldserver->Disconnect();
}
int main() {
RegisterExecutablePlatform(ExePlatformWebInterface);
set_exception_handler();
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
_log(WEB_INTERFACE__INIT, "Starting EQEmu Socket Server.");
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
_log(WEB_INTERFACE__ERROR, "Could not set signal handler");
return 1;
}
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
_log(WEB_INTERFACE__ERROR, "Could not set signal handler");
return 1;
}
config = EQEmuConfig::get();
worldserver = new WorldServer(config->SharedKey);
worldserver->Connect();
while(run) {
Timer::SetCurrentTime();
if (InterserverTimer.Check()) {
if (worldserver->TryReconnect() && (!worldserver->Connected()))
worldserver->AsyncConnect();
}
worldserver->Process();
timeout_manager.CheckTimeouts();
Sleep(10);
}
}
+62
View File
@@ -0,0 +1,62 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <stdarg.h>
#include "../common/servertalk.h"
#include "../common/packet_functions.h"
#include "../common/md5.h"
#include "../common/packet_dump.h"
#include "worldserver.h"
WorldServer::WorldServer(std::string shared_key)
: WorldConnection(EmuTCPConnection::packetModeWebInterface, shared_key.c_str()){
pTryReconnect = true;
}
WorldServer::~WorldServer(){
}
void WorldServer::OnConnected(){
_log(WEB_INTERFACE__INIT, "Connected to World.");
WorldConnection::OnConnected();
}
void WorldServer::Process(){
WorldConnection::Process();
if (!Connected())
return;
ServerPacket *pack = nullptr;
while((pack = tcpc.PopPacket())){
_log(WEB_INTERFACE__TRACE, "Received Opcode: %4X", pack->opcode);
switch(pack->opcode) {
case 0: { break; }
case ServerOP_KeepAlive: { break; }
}
}
safe_delete(pack);
return;
}
+35
View File
@@ -0,0 +1,35 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef WI_WORLDSERVER_H
#define WI_WORLDSERVER_H
#include "../common/worldconn.h"
#include "../common/eq_packet_structs.h"
class WorldServer : public WorldConnection
{
public:
WorldServer(std::string shared_key);
virtual ~WorldServer();
virtual void Process();
private:
virtual void OnConnected();
};
#endif