Position updates with do_pos_update test call

This commit is contained in:
Chris M
2014-07-22 23:14:44 -05:00
parent 69e90aac0a
commit da6d7538b0
10 changed files with 69 additions and 26 deletions
+13 -1
View File
@@ -7,6 +7,7 @@
#include "../common/crash.h"
#include "../common/EQEmuConfig.h"
#include "../common/web_interface_utils.h"
#include "../common/StringUtil.h"
#include "../common/uuid.h"
#include "worldserver.h"
#include "lib/libwebsockets.h"
@@ -62,7 +63,7 @@ int callback_eqemu(libwebsocket_context *context, libwebsocket *wsi, libwebsocke
session->uuid = CreateUUID();
session->send_queue = new std::list<std::string>();
sessions[session->uuid] = session;
printf("Create session %s\n", session->uuid.c_str());
printf("Created session %s\n", session->uuid.c_str());
break;
case LWS_CALLBACK_RECEIVE: {
@@ -76,6 +77,17 @@ int callback_eqemu(libwebsocket_context *context, libwebsocket *wsi, libwebsocke
if(command.compare("get_version") == 0) {
session->send_queue->push_back("0.8.0");
}
if (command.compare("do_pos_update") == 0){
printf("Sending ServerOP_WIClientRequest with session %s Command Str %s \n", session->uuid.c_str(), command.c_str());
/* Test Packet */
ServerPacket* pack = new ServerPacket(ServerOP_WIClientRequest, sizeof(WI_Client_Request_Struct) + command.length() + 1);
WI_Client_Request_Struct* WICR = (WI_Client_Request_Struct*)pack->pBuffer;
strn0cpy(WICR->Client_UUID, session->uuid.c_str(), 64);
strn0cpy(WICR->JSON_Data, command.c_str(), command.length() + 1);
worldserver->SendPacket(pack);
safe_delete(pack);
}
break;
}
case LWS_CALLBACK_SERVER_WRITEABLE: {
+18
View File
@@ -23,17 +23,24 @@
#include <time.h>
#include <stdlib.h>
#include <stdarg.h>
#include <list>
#include <map>
#include "../common/servertalk.h"
#include "../common/packet_functions.h"
#include "../common/md5.h"
#include "../common/packet_dump.h"
#include "../common/web_interface_utils.h"
#include "worldserver.h"
struct per_session_data_eqemu {
bool auth;
std::string uuid;
std::list<std::string> *send_queue;
};
extern std::map<std::string, per_session_data_eqemu*> sessions;
WorldServer::WorldServer(std::string shared_key)
: WorldConnection(EmuTCPConnection::packetModeWebInterface, shared_key.c_str()){
pTryReconnect = true;
@@ -59,6 +66,17 @@ void WorldServer::Process(){
case 0: { break; }
case ServerOP_KeepAlive: { break; }
case ServerOP_WIWorldResponse: {
/* Generic Response routine: web_interface server recieves packet from World -
Relays data back to client
*/
_log(WEB_INTERFACE__ERROR, "WI Recieved packet from world 0x%04x, size %d", pack->opcode, pack->size);
WI_Client_Request_Struct* WICR = (WI_Client_Request_Struct*)pack->pBuffer;
std::string Data;
Data.assign(WICR->JSON_Data, pack->size - 64);
/* Check if Session is Valid before sending data back*/
if (sessions[WICR->Client_UUID]){
sessions[WICR->Client_UUID]->send_queue->push_back(Data.c_str());
}
break;
}
}