diff --git a/web_interface/test/we.html b/web_interface/test/we.html
new file mode 100644
index 000000000..70147c2ba
--- /dev/null
+++ b/web_interface/test/we.html
@@ -0,0 +1,50 @@
+
+
+
+
+ WS
+
+
+
+
+
+
diff --git a/world/remote_call.cpp b/world/remote_call.cpp
index 2a35dbc2e..eb71d9fdd 100644
--- a/world/remote_call.cpp
+++ b/world/remote_call.cpp
@@ -90,7 +90,7 @@ void handle_rc_get_zone_info(const std::string &method, const std::string &conne
res["short_name"] = zs->GetZoneName();
res["long_name"] = zs->GetZoneLongName();
res["port"] = itoa(zs->GetCPort());
- res["num_players"] = itoa(zs->NumPlayers());
+ res["player_count"] = itoa(zs->NumPlayers());
RemoteCallResponse(connection_id, request_id, res, error);
}
diff --git a/zone/mob.cpp b/zone/mob.cpp
index 877fe336a..42b093caa 100644
--- a/zone/mob.cpp
+++ b/zone/mob.cpp
@@ -1216,32 +1216,16 @@ void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){
spu->padding0018 =0x5df27;
if(IsNPC()) {
- //zone_id
- //instance_id
- //entity_id
- //x
- //y
- //z
- //h
- const auto &conns = RemoteCallSubscriptionHandler::Instance()->GetSubscribers("NPC::MakeSpawnUpdateNoDelta");
- if(conns.size() > 0) {
- std::string method = "NPC::MakeSpawnUpdateNoDelta";
- std::vector params;
- params.push_back(std::to_string((long)zone->GetZoneID()));
- params.push_back(std::to_string((long)zone->GetInstanceID()));
- params.push_back(std::to_string((long)GetID()));
- params.push_back(GetName());
- params.push_back(std::to_string((double)x_pos));
- params.push_back(std::to_string((double)y_pos));
- params.push_back(std::to_string((double)z_pos));
- params.push_back(std::to_string((double)heading));
-
- auto &iter = conns.begin();
- while(iter != conns.end()) {
- RemoteCall((*iter), method, params);
- ++iter;
- }
- }
+ std::vector params;
+ params.push_back(std::to_string((long)zone->GetZoneID()));
+ params.push_back(std::to_string((long)zone->GetInstanceID()));
+ params.push_back(std::to_string((long)GetID()));
+ params.push_back(GetName());
+ params.push_back(std::to_string((double)x_pos));
+ params.push_back(std::to_string((double)y_pos));
+ params.push_back(std::to_string((double)z_pos));
+ params.push_back(std::to_string((double)heading));
+ RemoteCallSubscriptionHandler::Instance()->OnEvent("NPC::MakeSpawnUpdateNoDelta", params);
}
}
diff --git a/zone/remote_call_subscribe.cpp b/zone/remote_call_subscribe.cpp
index c39ac8b80..69440e520 100644
--- a/zone/remote_call_subscribe.cpp
+++ b/zone/remote_call_subscribe.cpp
@@ -7,6 +7,7 @@
#include "../common/packet_dump.h"
#include "../common/servertalk.h"
#include "remote_call_subscribe.h"
+#include "remote_call.h"
#include "worldserver.h"
#include "zone.h"
@@ -90,12 +91,28 @@ bool RemoteCallSubscriptionHandler::Unsubscribe(std::string connection_id, std::
return false;
}
+void RemoteCallSubscriptionHandler::OnEvent(std::string method, std::vector ¶ms) {
+ if(registered_events.count(method) == 0) {
+ return;
+ }
+
+ std::string func = "WebInterface::DispatchEvent::" + method;
+ std::vector &conns = registered_events[method];
+ if(conns.size() > 0) {
+ auto &iter = conns.begin();
+ while(iter != conns.end()) {
+ RemoteCall((*iter), func, params);
+ ++iter;
+ }
+ }
+}
+
void RemoteCallSubscriptionHandler::Process() {
//create a check for all these connection ids packet
uint32 sz = 12;
auto iter = connection_ids.begin();
while(iter != connection_ids.end()) {
- sz += iter->first.size();
+ sz += (uint32)iter->first.size();
sz += 5;
++iter;
}
@@ -116,15 +133,6 @@ void RemoteCallSubscriptionHandler::Process() {
safe_delete(pack);
}
-const std::vector &RemoteCallSubscriptionHandler::GetSubscribers(std::string event_name) {
- if(registered_events.count(event_name) == 0) {
- return std::vector();
- }
-
- std::vector &r = registered_events[event_name];
- return r;
-}
-
void RemoteCallSubscriptionHandler::ClearConnection(std::string connection_id) {
if(connection_ids.count(connection_id) != 0) {
connection_ids.erase(connection_id);
@@ -138,7 +146,6 @@ void RemoteCallSubscriptionHandler::ClearConnection(std::string connection_id) {
if(conn_iter->compare(connection_id) == 0) {
conns.erase(conn_iter);
registered_events[iter->first] = conns;
- printf("Removing connection: %s from event %s\n", connection_id.c_str(), iter->first.c_str());
break;
}
++conn_iter;
@@ -149,10 +156,6 @@ void RemoteCallSubscriptionHandler::ClearConnection(std::string connection_id) {
}
void RemoteCallSubscriptionHandler::ClearAllConnections() {
- //
- //std::map> registered_events;
- //std::map connection_ids;
-
registered_events.clear();
connection_ids.clear();
diff --git a/zone/remote_call_subscribe.h b/zone/remote_call_subscribe.h
index f82928f78..db0ae8c25 100644
--- a/zone/remote_call_subscribe.h
+++ b/zone/remote_call_subscribe.h
@@ -30,7 +30,7 @@ public:
static RemoteCallSubscriptionHandler *Instance();
bool Subscribe(std::string connection_id, std::string event_name);
bool Unsubscribe(std::string connection_id, std::string event_name);
- const std::vector &GetSubscribers(std::string event_name);
+ void OnEvent(std::string method, std::vector ¶ms);
void Process();
void ClearConnection(std::string connection_id);