mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 19:51:29 +00:00
Stuff
This commit is contained in:
parent
4e1fcfb7e5
commit
7c3cfd43de
@ -66,6 +66,7 @@ SET(common_sources
|
||||
unix.cpp
|
||||
uuid.cpp
|
||||
worldconn.cpp
|
||||
web_interface_utils.cpp
|
||||
XMLParser.cpp
|
||||
platform.cpp
|
||||
patches/Client62.cpp
|
||||
@ -189,6 +190,7 @@ SET(common_headers
|
||||
useperl.h
|
||||
version.h
|
||||
worldconn.h
|
||||
web_interface_utils.h
|
||||
XMLParser.h
|
||||
ZoneNumbers.h
|
||||
platform.h
|
||||
|
||||
@ -6,6 +6,7 @@ extern WorldServer *worldserver;
|
||||
extern std::map<std::string, std::pair<int, MethodHandler>> authorized_methods;
|
||||
extern std::map<std::string, MethodHandler> unauthorized_methods;
|
||||
|
||||
/* Web Interface */
|
||||
void register_authorized_methods()
|
||||
{
|
||||
authorized_methods["WebInterface.Authorize"] = std::make_pair(0, handle_method_token_auth);
|
||||
@ -13,6 +14,7 @@ void register_authorized_methods()
|
||||
authorized_methods["World.GetZoneDetails"] = std::make_pair(10, handle_method_get_zone_info);
|
||||
authorized_methods["Zone.Subscribe"] = std::make_pair(10, handle_method_subscribe);
|
||||
authorized_methods["Zone.Unsubscribe"] = std::make_pair(10, handle_method_subscribe);
|
||||
authorized_methods["Zone.GetInitialEntityPositions"] = std::make_pair(10, handle_method_void_event);
|
||||
}
|
||||
|
||||
void register_unauthorized_methods()
|
||||
@ -108,3 +110,30 @@ void handle_method_subscribe(per_session_data_eqemu *session, rapidjson::Documen
|
||||
worldserver->SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
void handle_method_void_event(per_session_data_eqemu *session, rapidjson::Document &document, std::string &method) {
|
||||
CheckParams(2, "[zone_id, instance_id]");
|
||||
VerifyID();
|
||||
CalculateSize();
|
||||
|
||||
ServerPacket *pack = new ServerPacket(ServerOP_WIRemoteCall, sz);
|
||||
pack->WriteUInt32((uint32)id.size());
|
||||
pack->WriteString(id.c_str());
|
||||
pack->WriteUInt32((uint32)session->uuid.size());
|
||||
pack->WriteString(session->uuid.c_str());
|
||||
pack->WriteUInt32((uint32)method.size());
|
||||
pack->WriteString(method.c_str());
|
||||
pack->WriteUInt32(2);
|
||||
|
||||
auto ¶ms = document["params"];
|
||||
auto ¶m = params[(rapidjson::SizeType)0];
|
||||
pack->WriteUInt32((uint32)strlen(param.GetString()));
|
||||
pack->WriteString(param.GetString());
|
||||
|
||||
param = params[1];
|
||||
pack->WriteUInt32((uint32)strlen(param.GetString()));
|
||||
pack->WriteString(param.GetString());
|
||||
|
||||
worldserver->SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
@ -61,6 +61,7 @@ void handle_method_token_auth(per_session_data_eqemu *session, rapidjson::Docume
|
||||
void handle_method_no_args(per_session_data_eqemu *session, rapidjson::Document &document, std::string &method);
|
||||
void handle_method_get_zone_info(per_session_data_eqemu *session, rapidjson::Document &document, std::string &method);
|
||||
void handle_method_subscribe(per_session_data_eqemu *session, rapidjson::Document &document, std::string &method);
|
||||
void handle_method_void_event(per_session_data_eqemu *session, rapidjson::Document &document, std::string &method);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -45,11 +45,13 @@ void RemoteCallResponse(const std::string &connection_id, const std::string &req
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
/* World */
|
||||
void register_remote_call_handlers() {
|
||||
remote_call_methods["World.ListZones"] = handle_rc_list_zones;
|
||||
remote_call_methods["World.GetZoneDetails"] = handle_rc_get_zone_info;
|
||||
remote_call_methods["Zone.Subscribe"] = handle_rc_relay;
|
||||
remote_call_methods["Zone.Unsubscribe"] = handle_rc_relay;
|
||||
remote_call_methods["Zone.GetInitialEntityPositions"] = handle_rc_relay;
|
||||
}
|
||||
|
||||
void handle_rc_list_zones(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector<std::string> ¶ms) {
|
||||
|
||||
@ -6,12 +6,18 @@
|
||||
#include "../common/packet_functions.h"
|
||||
#include "../common/packet_dump.h"
|
||||
#include "../common/servertalk.h"
|
||||
#include "../common/web_interface_utils.h"
|
||||
#include "remote_call.h"
|
||||
#include "remote_call_subscribe.h"
|
||||
#include "worldserver.h"
|
||||
#include "zone.h"
|
||||
#include "entity.h"
|
||||
#include "npc.h"
|
||||
#include <string>
|
||||
|
||||
std::map<std::string, RemoteCallHandler> remote_call_methods;
|
||||
extern WorldServer worldserver;
|
||||
extern Zone* zone;
|
||||
|
||||
void RemoteCallResponse(const std::string &connection_id, const std::string &request_id, const std::map<std::string, std::string> &res, const std::string &error) {
|
||||
uint32 sz = (uint32)(connection_id.size() + request_id.size() + error.size() + 3 + 16);
|
||||
@ -67,9 +73,44 @@ void RemoteCall(const std::string &connection_id, const std::string &method, con
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
/* Zone */
|
||||
void register_remote_call_handlers() {
|
||||
remote_call_methods["Zone.Subscribe"] = handle_rc_subscribe;
|
||||
remote_call_methods["Zone.Unsubscribe"] = handle_rc_unsubscribe;
|
||||
remote_call_methods["Zone.GetInitialEntityPositions"] = handle_rc_get_initial_entity_positions;
|
||||
}
|
||||
|
||||
void handle_rc_get_initial_entity_positions(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector<std::string> ¶ms) {
|
||||
std::string error;
|
||||
std::map<std::string, std::string> res;
|
||||
|
||||
int16 i = 0;
|
||||
std::list<NPC*> npc_list;
|
||||
entity_list.GetNPCList(npc_list);
|
||||
for (std::list<NPC*>::iterator itr = npc_list.begin(); itr != npc_list.end(); ++itr) {
|
||||
NPC* npc = *itr;
|
||||
// res[std::to_string(npc->GetID())] = MakeJSON(
|
||||
// "zone_id:" + std::to_string(zone->GetZoneID()) +
|
||||
// ",inst_id:" + std::to_string(zone->GetInstanceID()) +
|
||||
// ",ent_id:" + std::to_string(npc->GetID()) +
|
||||
// ",name:" + npc->GetName() +
|
||||
// ",x:" + std::to_string(npc->GetX()) +
|
||||
// ",y:" + std::to_string(npc->GetX()) +
|
||||
// ",z:" + std::to_string(npc->GetX()) +
|
||||
// ",h:" + std::to_string(npc->GetHeading())
|
||||
// );
|
||||
res["zone_id"] = itoa(zone->GetZoneID());
|
||||
res["instance_id"] = itoa(zone->GetInstanceID());
|
||||
res["ent_id"] = itoa(npc->GetID());
|
||||
res["name"] = npc->GetName();
|
||||
res["x"] = itoa(npc->GetX());
|
||||
res["y"] = itoa(npc->GetY());
|
||||
res["z"] = itoa(npc->GetZ());
|
||||
res["h"] = itoa(npc->GetHeading());
|
||||
RemoteCallResponse(connection_id, request_id, res, error);
|
||||
i++;
|
||||
printf("Response ent pos %i \n", i);
|
||||
}
|
||||
}
|
||||
|
||||
void handle_rc_subscribe(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector<std::string> ¶ms) {
|
||||
|
||||
@ -29,6 +29,7 @@ void RemoteCall(const std::string &connection_id, const std::string &method, con
|
||||
|
||||
void register_remote_call_handlers();
|
||||
|
||||
void handle_rc_get_initial_entity_positions(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector<std::string> ¶ms);
|
||||
void handle_rc_subscribe(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector<std::string> ¶ms);
|
||||
void handle_rc_unsubscribe(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector<std::string> ¶ms);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user