mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Add client and zone subscriptions
This commit is contained in:
parent
83b51b04d3
commit
28325467da
@ -2,7 +2,8 @@ const WebSocket = require('ws');
|
||||
const ws = new WebSocket('ws://localhost:9080');
|
||||
|
||||
ws.on('open', function open() {
|
||||
ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg0NzIzNDQxLCJpYXQiOjE0ODQxMTg2NDF9.Lmwm572yMWIu1DUrfer8JVvl1DGEkdnMsMFp5WDzp_A', id: '1', method: 'EQW::Subscribe::WorldZoneUpdate', params: []}));
|
||||
//ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg0NzIzNDQxLCJpYXQiOjE0ODQxMTg2NDF9.Lmwm572yMWIu1DUrfer8JVvl1DGEkdnMsMFp5WDzp_A', method: 'EQW::ZoneUpdate::Subscribe'}));
|
||||
ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg0NzIzNDQxLCJpYXQiOjE0ODQxMTg2NDF9.Lmwm572yMWIu1DUrfer8JVvl1DGEkdnMsMFp5WDzp_A', method: 'EQW::ClientUpdate::Subscribe'}));
|
||||
});
|
||||
|
||||
ws.on('message', function(data, flags) {
|
||||
|
||||
@ -4,7 +4,8 @@ var RegisterEQW = function(wsi, api) {
|
||||
common.Register('EQW::IsLocked', wsi, api);
|
||||
common.Register('EQW::Lock', wsi, api);
|
||||
common.Register('EQW::Unlock', wsi, api);
|
||||
common.RegisterSubscription('EQW', 'WorldZoneUpdate', wsi, api);
|
||||
common.RegisterSubscription('EQW::ZoneUpdate', wsi, api);
|
||||
common.RegisterSubscription('EQW::ClientUpdate', wsi, api);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
@ -11,12 +11,12 @@ function Register(name, wsi, api) {
|
||||
}, true);
|
||||
}
|
||||
|
||||
function RegisterSubscription(namespace, event, wsi, api) {
|
||||
wsi.Register(namespace + '::Subscribe::' + event, function(request) {
|
||||
function RegisterSubscription(event, wsi, api) {
|
||||
wsi.Register(event + '::Subscribe', function(request) {
|
||||
api.Subscribe(event, request.ws);
|
||||
});
|
||||
|
||||
wsi.Register(namespace + '::Unsubscribe::' + event, function(request) {
|
||||
wsi.Register(event + '::Unsubscribe', function(request) {
|
||||
api.Unsubscribe(event, request.ws);
|
||||
});
|
||||
}
|
||||
|
||||
@ -46,6 +46,10 @@ ClientListEntry::ClientListEntry(uint32 in_id, uint32 iLSID, const char* iLoginN
|
||||
plocal=(local==1);
|
||||
|
||||
pinstance = 0;
|
||||
pLFGFromLevel = 0;
|
||||
pLFGToLevel = 0;
|
||||
pLFGMatchFilter = false;
|
||||
memset(pLFGComments, 0, 64);
|
||||
}
|
||||
|
||||
ClientListEntry::ClientListEntry(uint32 in_id, uint32 iAccID, const char* iAccName, MD5& iMD5Pass, int16 iAdmin)
|
||||
@ -63,6 +67,10 @@ ClientListEntry::ClientListEntry(uint32 in_id, uint32 iAccID, const char* iAccNa
|
||||
padmin = iAdmin;
|
||||
|
||||
pinstance = 0;
|
||||
pLFGFromLevel = 0;
|
||||
pLFGToLevel = 0;
|
||||
pLFGMatchFilter = false;
|
||||
memset(pLFGComments, 0, 64);
|
||||
}
|
||||
|
||||
ClientListEntry::ClientListEntry(uint32 in_id, ZoneServer* iZS, ServerClientList_Struct* scl, int8 iOnline)
|
||||
@ -81,6 +89,10 @@ ClientListEntry::ClientListEntry(uint32 in_id, ZoneServer* iZS, ServerClientList
|
||||
padmin = scl->Admin;
|
||||
|
||||
pinstance = 0;
|
||||
pLFGFromLevel = 0;
|
||||
pLFGToLevel = 0;
|
||||
pLFGMatchFilter = false;
|
||||
memset(pLFGComments, 0, 64);
|
||||
|
||||
if (iOnline >= CLE_Status_Zoning)
|
||||
Update(iZS, scl, iOnline);
|
||||
|
||||
@ -29,10 +29,13 @@
|
||||
#include "../common/packet_dump.h"
|
||||
#include "../common/misc.h"
|
||||
#include "../common/misc_functions.h"
|
||||
#include "../common/json/json.h"
|
||||
#include "web_interface.h"
|
||||
#include "wguild_mgr.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
extern WebInterfaceList web_interface;
|
||||
|
||||
extern ZSList zoneserver_list;
|
||||
uint32 numplayers = 0; //this really wants to be a member variable of ClientList...
|
||||
|
||||
@ -40,6 +43,8 @@ ClientList::ClientList()
|
||||
: CLStale_timer(45000)
|
||||
{
|
||||
NextCLEID = 1;
|
||||
|
||||
m_tick.reset(new EQ::Timer(1000, true, std::bind(&ClientList::OnTick, this, std::placeholders::_1)));
|
||||
}
|
||||
|
||||
ClientList::~ClientList() {
|
||||
@ -1358,3 +1363,83 @@ void ClientList::SendClientVersionSummary(const char *Name)
|
||||
ClientTitaniumCount, ClientSoFCount, ClientSoDCount, ClientUnderfootCount, ClientRoFCount, ClientRoF2Count);
|
||||
}
|
||||
|
||||
void ClientList::OnTick(EQ::Timer *t)
|
||||
{
|
||||
Json::Value out;
|
||||
out["event"] = "EQW::ClientUpdate";
|
||||
out["data"] = Json::Value();
|
||||
|
||||
LinkedListIterator<ClientListEntry*> Iterator(clientlist);
|
||||
|
||||
Iterator.Reset();
|
||||
|
||||
while (Iterator.MoreElements())
|
||||
{
|
||||
ClientListEntry* cle = Iterator.GetData();
|
||||
|
||||
Json::Value outclient;
|
||||
|
||||
outclient["Online"] = cle->Online();
|
||||
outclient["ID"] = cle->GetID();
|
||||
outclient["IP"] = cle->GetIP();
|
||||
outclient["LSID"] = cle->LSID();
|
||||
outclient["LSAccountID"] = cle->LSAccountID();
|
||||
outclient["LSName"] = cle->LSName();
|
||||
outclient["WorldAdmin"] = cle->WorldAdmin();
|
||||
|
||||
outclient["AccountID"] = cle->AccountID();
|
||||
outclient["AccountName"] = cle->AccountName();
|
||||
outclient["Admin"] = cle->Admin();
|
||||
|
||||
auto server = cle->Server();
|
||||
if (server) {
|
||||
outclient["Server"]["CAddress"] = server->GetCAddress();
|
||||
outclient["Server"]["CLocalAddress"] = server->GetCLocalAddress();
|
||||
outclient["Server"]["CompileTime"] = server->GetCompileTime();
|
||||
outclient["Server"]["CPort"] = server->GetCPort();
|
||||
outclient["Server"]["ID"] = server->GetID();
|
||||
outclient["Server"]["InstanceID"] = server->GetInstanceID();
|
||||
outclient["Server"]["IP"] = server->GetIP();
|
||||
outclient["Server"]["LaunchedName"] = server->GetLaunchedName();
|
||||
outclient["Server"]["LaunchName"] = server->GetLaunchName();
|
||||
outclient["Server"]["Port"] = server->GetPort();
|
||||
outclient["Server"]["PrevZoneID"] = server->GetPrevZoneID();
|
||||
outclient["Server"]["UUID"] = server->GetUUID();
|
||||
outclient["Server"]["ZoneID"] = server->GetZoneID();
|
||||
outclient["Server"]["ZoneLongName"] = server->GetZoneLongName();
|
||||
outclient["Server"]["ZoneName"] = server->GetZoneName();
|
||||
outclient["Server"]["ZoneOSProcessID"] = server->GetZoneOSProcessID();
|
||||
outclient["Server"]["NumPlayers"] = server->NumPlayers();
|
||||
outclient["Server"]["BootingUp"] = server->IsBootingUp();
|
||||
outclient["Server"]["StaticZone"] = server->IsStaticZone();
|
||||
}
|
||||
else {
|
||||
outclient["Server"] = Json::Value();
|
||||
}
|
||||
|
||||
outclient["CharID"] = cle->CharID();
|
||||
outclient["name"] = cle->name();
|
||||
outclient["zone"] = cle->zone();
|
||||
outclient["instance"] = cle->instance();
|
||||
outclient["level"] = cle->level();
|
||||
outclient["class_"] = cle->class_();
|
||||
outclient["race"] = cle->race();
|
||||
outclient["Anon"] = cle->Anon();
|
||||
|
||||
outclient["TellsOff"] = cle->TellsOff();
|
||||
outclient["GuildID"] = cle->GuildID();
|
||||
outclient["LFG"] = cle->LFG();
|
||||
outclient["GM"] = cle->GetGM();
|
||||
outclient["LocalClient"] = cle->IsLocalClient();
|
||||
outclient["LFGFromLevel"] = cle->GetLFGFromLevel();
|
||||
outclient["LFGToLevel"] = cle->GetLFGToLevel();
|
||||
outclient["LFGMatchFilter"] = cle->GetLFGMatchFilter();
|
||||
outclient["LFGComments"] = cle->GetLFGComments();
|
||||
outclient["ClientVersion"] = cle->GetClientVersion();
|
||||
out["data"].append(outclient);
|
||||
|
||||
Iterator.Advance();
|
||||
}
|
||||
|
||||
web_interface.SendEvent(out);
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
#include "../common/timer.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/servertalk.h"
|
||||
#include "../common/event/timer.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@ -66,7 +67,8 @@ public:
|
||||
int GetClientCount();
|
||||
void GetClients(const char *zone_name, std::vector<ClientListEntry *> &into);
|
||||
|
||||
protected:
|
||||
private:
|
||||
void OnTick(EQ::Timer *t);
|
||||
inline uint32 GetNextCLEID() { return NextCLEID++; }
|
||||
|
||||
//this is the list of people actively connected to zone
|
||||
@ -77,6 +79,7 @@ protected:
|
||||
uint32 NextCLEID;
|
||||
LinkedList<ClientListEntry *> clientlist;
|
||||
|
||||
std::unique_ptr<EQ::Timer> m_tick;
|
||||
};
|
||||
|
||||
#endif /*CLIENTLIST_H_*/
|
||||
|
||||
@ -699,7 +699,7 @@ void ZSList::WorldShutDown(uint32 time, uint32 interval)
|
||||
void ZSList::OnTick(EQ::Timer *t)
|
||||
{
|
||||
Json::Value out;
|
||||
out["event"] = "WorldZoneUpdate";
|
||||
out["event"] = "EQW::ZoneUpdate";
|
||||
out["data"] = Json::Value();
|
||||
|
||||
for (auto &zone : list)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user