mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 19:51:29 +00:00
Will be redoing the event interface for subscriptions, some work for the wi and crash fixes
This commit is contained in:
parent
a8699eb40c
commit
d5bd773a46
@ -27,6 +27,7 @@ SET(common_sources
|
|||||||
eq_stream_ident.cpp
|
eq_stream_ident.cpp
|
||||||
eq_stream_proxy.cpp
|
eq_stream_proxy.cpp
|
||||||
eqtime.cpp
|
eqtime.cpp
|
||||||
|
event_sub.cpp
|
||||||
extprofile.cpp
|
extprofile.cpp
|
||||||
faction.cpp
|
faction.cpp
|
||||||
guild_base.cpp
|
guild_base.cpp
|
||||||
@ -139,6 +140,7 @@ SET(common_headers
|
|||||||
eq_stream_proxy.h
|
eq_stream_proxy.h
|
||||||
eqtime.h
|
eqtime.h
|
||||||
errmsg.h
|
errmsg.h
|
||||||
|
event_sub.h
|
||||||
extprofile.h
|
extprofile.h
|
||||||
faction.h
|
faction.h
|
||||||
features.h
|
features.h
|
||||||
|
|||||||
22
common/event_sub.cpp
Normal file
22
common/event_sub.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "event_sub.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void EventSubscriptionWatcher::Subscribe(const std::string &event_name)
|
||||||
|
{
|
||||||
|
m_subs[event_name] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventSubscriptionWatcher::Unsubscribe(const std::string &event_name)
|
||||||
|
{
|
||||||
|
m_subs[event_name] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EventSubscriptionWatcher::IsSubscribed(const std::string &event_name) const
|
||||||
|
{
|
||||||
|
auto iter = m_subs.find(event_name);
|
||||||
|
if (iter != m_subs.end()) {
|
||||||
|
return iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
28
common/event_sub.h
Normal file
28
common/event_sub.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
class EventSubscriptionWatcher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~EventSubscriptionWatcher();
|
||||||
|
|
||||||
|
void Subscribe(const std::string &event_name);
|
||||||
|
void Unsubscribe(const std::string &event_name);
|
||||||
|
bool IsSubscribed(const std::string &event_name) const;
|
||||||
|
|
||||||
|
static EventSubscriptionWatcher *Get() {
|
||||||
|
static EventSubscriptionWatcher* inst = nullptr;
|
||||||
|
if(!inst) {
|
||||||
|
inst = new EventSubscriptionWatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
EventSubscriptionWatcher();
|
||||||
|
EventSubscriptionWatcher(const EventSubscriptionWatcher&);
|
||||||
|
EventSubscriptionWatcher& operator=(const EventSubscriptionWatcher&);
|
||||||
|
|
||||||
|
std::unordered_map<std::string, bool> m_subs;
|
||||||
|
};
|
||||||
@ -89,6 +89,8 @@
|
|||||||
#define ServerOP_RequestTellQueue 0x0066 // client asks for it's tell queues
|
#define ServerOP_RequestTellQueue 0x0066 // client asks for it's tell queues
|
||||||
#define ServerOP_ChangeSharedMem 0x0067
|
#define ServerOP_ChangeSharedMem 0x0067
|
||||||
#define ServerOP_WebInterfaceEvent 0x0068
|
#define ServerOP_WebInterfaceEvent 0x0068
|
||||||
|
#define ServerOP_WebInterfaceSubscribe 0x0069
|
||||||
|
#define ServerOP_WebInterfaceUnsubscribe 0x0070
|
||||||
|
|
||||||
#define ServerOP_RaidAdd 0x0100 //in use
|
#define ServerOP_RaidAdd 0x0100 //in use
|
||||||
#define ServerOP_RaidRemove 0x0101 //in use
|
#define ServerOP_RaidRemove 0x0101 //in use
|
||||||
|
|||||||
26
wi/http/common.js
Normal file
26
wi/http/common.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
var auth = require('../core/jwt_auth.js').auth;
|
||||||
|
|
||||||
|
function RegisterFunction(path, fn, app, api) {
|
||||||
|
app.post(path, auth, function (req, res) {
|
||||||
|
var params = req.body.params || [];
|
||||||
|
|
||||||
|
api.Call(fn, params)
|
||||||
|
.then(function(value) {
|
||||||
|
res.send({ response: value });
|
||||||
|
})
|
||||||
|
.catch(function(reason) {
|
||||||
|
if(reason.message) {
|
||||||
|
res.send({ status: reason.message });
|
||||||
|
}
|
||||||
|
else if(reason === 'Not connected to world server.') {
|
||||||
|
res.send({ status: 'ENCONNECTED' });
|
||||||
|
} else {
|
||||||
|
res.sendStatus(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
'Register': RegisterFunction
|
||||||
|
}
|
||||||
@ -1,35 +1,14 @@
|
|||||||
var auth = require('../core/jwt_auth.js').auth;
|
const common = require('./common.js');
|
||||||
|
|
||||||
var RegisterEQW = function(app, api) {
|
var RegisterEQW = function(app, api) {
|
||||||
app.post('/api/eqw/islocked', auth, function (req, res) {
|
common.Register('/api/eqw/getconfig', 'EQW::GetConfig', app, api);
|
||||||
api.Call('EQW::IsLocked', [])
|
common.Register('/api/eqw/islocked', 'EQW::IsLocked', app, api);
|
||||||
.then(function(value) {
|
common.Register('/api/eqw/lock', 'EQW::Lock', app, api);
|
||||||
res.send({ response: value });
|
common.Register('/api/eqw/unlock', 'EQW::Unlock', app, api);
|
||||||
})
|
common.Register('/api/eqw/getplayercount', 'EQW::GetPlayerCount', app, api);
|
||||||
.catch(function(reason) {
|
common.Register('/api/eqw/getzonecount', 'EQW::GetZoneCount', app, api);
|
||||||
res.sendStatus(500);
|
common.Register('/api/eqw/getlaunchercount', 'EQW::GetLauncherCount', app, api);
|
||||||
});
|
common.Register('/api/eqw/getloginservercount', 'EQW::GetLoginServerCount', app, api);
|
||||||
});
|
|
||||||
|
|
||||||
app.post('/api/eqw/lock', auth, function (req, res) {
|
|
||||||
api.Call('EQW::Lock', [])
|
|
||||||
.then(function(value) {
|
|
||||||
res.send({ response: value });
|
|
||||||
})
|
|
||||||
.catch(function(reason) {
|
|
||||||
res.sendStatus(500);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post('/api/eqw/unlock', auth, function (req, res) {
|
|
||||||
api.Call('EQW::Unlock', [])
|
|
||||||
.then(function(value) {
|
|
||||||
res.send({ response: value });
|
|
||||||
})
|
|
||||||
.catch(function(reason) {
|
|
||||||
res.sendStatus(500);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -113,20 +113,26 @@ class ServertalkAPI
|
|||||||
|
|
||||||
var subs = this.subscriptions[event_id];
|
var subs = this.subscriptions[event_id];
|
||||||
if(subs) {
|
if(subs) {
|
||||||
console.log('Subscribe', who.uuid, 'to', event_id);
|
//console.log('Subscribe', who.uuid, 'to', event_id);
|
||||||
subs[who.uuid] = who;
|
subs[who.uuid] = who;
|
||||||
} else {
|
} else {
|
||||||
console.log('Subscribe', who.uuid, 'to', event_id);
|
//console.log('Subscribe', who.uuid, 'to', event_id);
|
||||||
this.subscriptions[event_id] = { };
|
this.subscriptions[event_id] = { };
|
||||||
this.subscriptions[event_id][who.uuid] = who;
|
this.subscriptions[event_id][who.uuid] = who;
|
||||||
|
//Tell our server we have a subscription for event_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Unsubscribe(event_id, who) {
|
Unsubscribe(event_id, who) {
|
||||||
var subs = this.subscriptions[event_id];
|
var subs = this.subscriptions[event_id];
|
||||||
if(subs) {
|
if(subs) {
|
||||||
console.log('Unsubscribe', who.uuid, 'from', event_id);
|
//console.log('Unsubscribe', who.uuid, 'from', event_id);
|
||||||
delete subs[who.uuid];
|
delete subs[who.uuid];
|
||||||
|
|
||||||
|
if(Object.keys(subs).length === 0) {
|
||||||
|
delete this.subscriptions[event_id];
|
||||||
|
//Tell our server we no longer have a subscription for event_id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@ const WebSocket = require('ws');
|
|||||||
const ws = new WebSocket('ws://localhost:9080');
|
const ws = new WebSocket('ws://localhost:9080');
|
||||||
|
|
||||||
ws.on('open', function open() {
|
ws.on('open', function open() {
|
||||||
//ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg0NzIzNDQxLCJpYXQiOjE0ODQxMTg2NDF9.Lmwm572yMWIu1DUrfer8JVvl1DGEkdnMsMFp5WDzp_A', method: 'EQW::ZoneUpdate::Subscribe'}));
|
ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg2MzI4MDI3LCJpYXQiOjE0ODU3MjMyMjd9.fJUeSQsxb5C13ICANox81YdE5yImkrVw-lRCP3O40-E', method: 'EQW::ZoneUpdate::Subscribe'}));
|
||||||
ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg0NzIzNDQxLCJpYXQiOjE0ODQxMTg2NDF9.Lmwm572yMWIu1DUrfer8JVvl1DGEkdnMsMFp5WDzp_A', method: 'EQW::ClientUpdate::Subscribe'}));
|
ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg2MzI4MDI3LCJpYXQiOjE0ODU3MjMyMjd9.fJUeSQsxb5C13ICANox81YdE5yImkrVw-lRCP3O40-E', method: 'EQW::ClientUpdate::Subscribe'}));
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('message', function(data, flags) {
|
ws.on('message', function(data, flags) {
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
const common = require('./wi_common.js');
|
const common = require('./wi_common.js');
|
||||||
|
|
||||||
var RegisterEQW = function(wsi, api) {
|
var RegisterEQW = function(wsi, api) {
|
||||||
|
common.Register('EQW::GetConfig', wsi, api);
|
||||||
common.Register('EQW::IsLocked', wsi, api);
|
common.Register('EQW::IsLocked', wsi, api);
|
||||||
common.Register('EQW::Lock', wsi, api);
|
common.Register('EQW::Lock', wsi, api);
|
||||||
common.Register('EQW::Unlock', wsi, api);
|
common.Register('EQW::Unlock', wsi, api);
|
||||||
|
common.Register('EQW::GetPlayerCount', wsi, api);
|
||||||
|
common.Register('EQW::GetZoneCount', wsi, api);
|
||||||
|
common.Register('EQW::GetLauncherCount', wsi, api);
|
||||||
|
common.Register('EQW::GetLoginServerCount', wsi, api);
|
||||||
common.RegisterSubscription('EQW::ZoneUpdate', wsi, api);
|
common.RegisterSubscription('EQW::ZoneUpdate', wsi, api);
|
||||||
common.RegisterSubscription('EQW::ClientUpdate', wsi, api);
|
common.RegisterSubscription('EQW::ClientUpdate', wsi, api);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#include "../common/misc.h"
|
#include "../common/misc.h"
|
||||||
#include "../common/misc_functions.h"
|
#include "../common/misc_functions.h"
|
||||||
#include "../common/json/json.h"
|
#include "../common/json/json.h"
|
||||||
|
#include "../common/event_sub.h"
|
||||||
#include "web_interface.h"
|
#include "web_interface.h"
|
||||||
#include "wguild_mgr.h"
|
#include "wguild_mgr.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -1365,6 +1366,10 @@ void ClientList::SendClientVersionSummary(const char *Name)
|
|||||||
|
|
||||||
void ClientList::OnTick(EQ::Timer *t)
|
void ClientList::OnTick(EQ::Timer *t)
|
||||||
{
|
{
|
||||||
|
if (!EventSubscriptionWatcher::Get()->IsSubscribed("EQW::ClientUpdate")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value out;
|
Json::Value out;
|
||||||
out["event"] = "EQW::ClientUpdate";
|
out["event"] = "EQW::ClientUpdate";
|
||||||
out["data"] = Json::Value();
|
out["data"] = Json::Value();
|
||||||
|
|||||||
@ -52,112 +52,89 @@ LoginServerList::~LoginServerList() {
|
|||||||
void LoginServerList::Add(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool Legacy)
|
void LoginServerList::Add(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool Legacy)
|
||||||
{
|
{
|
||||||
auto loginserver = new LoginServer(iAddress, iPort, Account, Password, Legacy);
|
auto loginserver = new LoginServer(iAddress, iPort, Account, Password, Legacy);
|
||||||
list.Insert(loginserver);
|
m_list.push_back(std::unique_ptr<LoginServer>(loginserver));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::SendInfo() {
|
bool LoginServerList::SendInfo() {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
for (auto &iter : m_list) {
|
||||||
|
(*iter).SendInfo();
|
||||||
iterator.Reset();
|
|
||||||
while(iterator.MoreElements()){
|
|
||||||
iterator.GetData()->SendInfo();
|
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::SendNewInfo() {
|
bool LoginServerList::SendNewInfo() {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
for (auto &iter : m_list) {
|
||||||
|
(*iter).SendNewInfo();
|
||||||
iterator.Reset();
|
|
||||||
while(iterator.MoreElements()){
|
|
||||||
iterator.GetData()->SendNewInfo();
|
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::SendStatus() {
|
bool LoginServerList::SendStatus() {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
for (auto &iter : m_list) {
|
||||||
|
(*iter).SendStatus();
|
||||||
iterator.Reset();
|
|
||||||
while(iterator.MoreElements()){
|
|
||||||
iterator.GetData()->SendStatus();
|
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::SendPacket(ServerPacket* pack) {
|
bool LoginServerList::SendPacket(ServerPacket* pack) {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
for (auto &iter : m_list) {
|
||||||
|
(*iter).SendPacket(pack);
|
||||||
iterator.Reset();
|
|
||||||
while(iterator.MoreElements()){
|
|
||||||
iterator.GetData()->SendPacket(pack);
|
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::SendAccountUpdate(ServerPacket* pack) {
|
bool LoginServerList::SendAccountUpdate(ServerPacket* pack) {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::World_Server, "Requested to send ServerOP_LSAccountUpdate packet to all loginservers");
|
Log.Out(Logs::Detail, Logs::World_Server, "Requested to send ServerOP_LSAccountUpdate packet to all loginservers");
|
||||||
iterator.Reset();
|
for (auto &iter : m_list) {
|
||||||
while(iterator.MoreElements()){
|
if ((*iter).CanUpdate()) {
|
||||||
if(iterator.GetData()->CanUpdate()) {
|
(*iter).SendAccountUpdate(pack);
|
||||||
iterator.GetData()->SendAccountUpdate(pack);
|
|
||||||
}
|
}
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::Connected() {
|
bool LoginServerList::Connected() {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
for (auto &iter : m_list) {
|
||||||
|
if ((*iter).Connected()) {
|
||||||
iterator.Reset();
|
|
||||||
while(iterator.MoreElements()){
|
|
||||||
if(iterator.GetData()->Connected())
|
|
||||||
return true;
|
return true;
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::AllConnected() {
|
bool LoginServerList::AllConnected() {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
for (auto &iter : m_list) {
|
||||||
|
if (!(*iter).Connected()) {
|
||||||
iterator.Reset();
|
|
||||||
while(iterator.MoreElements()){
|
|
||||||
if(iterator.GetData()->Connected() == false)
|
|
||||||
return false;
|
return false;
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::MiniLogin() {
|
bool LoginServerList::MiniLogin() {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
for (auto &iter : m_list) {
|
||||||
|
if ((*iter).MiniLogin()) {
|
||||||
iterator.Reset();
|
|
||||||
while(iterator.MoreElements()){
|
|
||||||
if(iterator.GetData()->MiniLogin())
|
|
||||||
return true;
|
return true;
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginServerList::CanUpdate() {
|
bool LoginServerList::CanUpdate() {
|
||||||
LinkedListIterator<LoginServer*> iterator(list);
|
for (auto &iter : m_list) {
|
||||||
|
if ((*iter).CanUpdate()) {
|
||||||
iterator.Reset();
|
|
||||||
while(iterator.MoreElements()){
|
|
||||||
if(iterator.GetData()->CanUpdate())
|
|
||||||
return true;
|
return true;
|
||||||
iterator.Advance();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,11 @@
|
|||||||
#define LOGINSERVERLIST_H_
|
#define LOGINSERVERLIST_H_
|
||||||
|
|
||||||
#include "../common/servertalk.h"
|
#include "../common/servertalk.h"
|
||||||
#include "../common/linked_list.h"
|
|
||||||
#include "../common/timer.h"
|
#include "../common/timer.h"
|
||||||
#include "../common/queue.h"
|
#include "../common/queue.h"
|
||||||
#include "../common/eq_packet_structs.h"
|
#include "../common/eq_packet_structs.h"
|
||||||
#include "../common/mutex.h"
|
#include "../common/mutex.h"
|
||||||
|
#include <list>
|
||||||
|
|
||||||
class LoginServer;
|
class LoginServer;
|
||||||
|
|
||||||
@ -27,9 +27,10 @@ public:
|
|||||||
bool AllConnected();
|
bool AllConnected();
|
||||||
bool MiniLogin();
|
bool MiniLogin();
|
||||||
bool CanUpdate();
|
bool CanUpdate();
|
||||||
|
size_t GetServerCount() const { return m_list.size(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LinkedList<LoginServer*> list;
|
std::list<std::unique_ptr<LoginServer>> m_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,8 +21,10 @@ void UCSConnection::SetConnection(std::shared_ptr<EQ::Net::ServertalkServerConne
|
|||||||
}
|
}
|
||||||
|
|
||||||
Stream = inStream;
|
Stream = inStream;
|
||||||
|
if (Stream) {
|
||||||
Stream->OnMessage(std::bind(&UCSConnection::ProcessPacket, this, std::placeholders::_1, std::placeholders::_2));
|
Stream->OnMessage(std::bind(&UCSConnection::ProcessPacket, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p)
|
void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -65,7 +65,7 @@ void WebInterface::OnCall(uint16 opcode, EQ::Net::Packet &p)
|
|||||||
auto iter = m_calls.find(method);
|
auto iter = m_calls.find(method);
|
||||||
if (iter == m_calls.end()) {
|
if (iter == m_calls.end()) {
|
||||||
//if not exist then error
|
//if not exist then error
|
||||||
SendError("Invalid request: method not found");
|
SendError("Invalid request: method not found", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +99,7 @@ void WebInterface::SendError(const std::string &message)
|
|||||||
void WebInterface::SendError(const std::string &message, const std::string &id)
|
void WebInterface::SendError(const std::string &message, const std::string &id)
|
||||||
{
|
{
|
||||||
Json::Value error;
|
Json::Value error;
|
||||||
|
error["id"] = id;
|
||||||
error["error"] = Json::Value();
|
error["error"] = Json::Value();
|
||||||
error["error"]["message"] = message;
|
error["error"]["message"] = message;
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,29 @@
|
|||||||
#include "web_interface.h"
|
#include "web_interface.h"
|
||||||
#include "world_config.h"
|
#include "world_config.h"
|
||||||
#include "login_server_list.h"
|
#include "login_server_list.h"
|
||||||
|
#include "clientlist.h"
|
||||||
|
#include "zonelist.h"
|
||||||
|
#include "launcher_list.h"
|
||||||
|
|
||||||
extern LoginServerList loginserverlist;
|
extern LoginServerList loginserverlist;
|
||||||
|
extern ClientList client_list;
|
||||||
|
extern ZSList zoneserver_list;
|
||||||
|
extern LauncherList launcher_list;
|
||||||
|
|
||||||
|
void EQW__GetConfig(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) {
|
||||||
|
if (params.isArray() && params.size() == 1) {
|
||||||
|
auto config_name = params[0];
|
||||||
|
if (config_name.isString()) {
|
||||||
|
auto config = config_name.asString();
|
||||||
|
|
||||||
|
Json::Value ret = WorldConfig::get()->GetByName(config);
|
||||||
|
i->SendResponse(id, ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i->SendError("EBADPARAMS", id);
|
||||||
|
}
|
||||||
|
|
||||||
void EQW__IsLocked(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) {
|
void EQW__IsLocked(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) {
|
||||||
Json::Value ret = WorldConfig::get()->Locked;
|
Json::Value ret = WorldConfig::get()->Locked;
|
||||||
@ -32,9 +53,34 @@ void EQW__Unlock(WebInterface *i, const std::string& method, const std::string&
|
|||||||
i->SendResponse(id, ret);
|
i->SendResponse(id, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EQW__GetPlayerCount(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) {
|
||||||
|
Json::Value ret = client_list.GetClientCount();
|
||||||
|
i->SendResponse(id, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQW__GetZoneCount(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) {
|
||||||
|
Json::Value ret = zoneserver_list.GetZoneCount();
|
||||||
|
i->SendResponse(id, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQW__GetLauncherCount(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) {
|
||||||
|
Json::Value ret = launcher_list.GetLauncherCount();
|
||||||
|
i->SendResponse(id, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQW__GetLoginServerCount(WebInterface *i, const std::string& method, const std::string& id, const Json::Value& params) {
|
||||||
|
Json::Value ret = loginserverlist.GetServerCount();
|
||||||
|
i->SendResponse(id, ret);
|
||||||
|
}
|
||||||
|
|
||||||
void RegisterEQW(WebInterface *i)
|
void RegisterEQW(WebInterface *i)
|
||||||
{
|
{
|
||||||
|
i->AddCall("EQW::GetConfig", std::bind(EQW__GetConfig, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
i->AddCall("EQW::IsLocked", std::bind(EQW__IsLocked, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
i->AddCall("EQW::IsLocked", std::bind(EQW__IsLocked, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
i->AddCall("EQW::Lock", std::bind(EQW__Lock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
i->AddCall("EQW::Lock", std::bind(EQW__Lock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
i->AddCall("EQW::Unlock", std::bind(EQW__Unlock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
i->AddCall("EQW::Unlock", std::bind(EQW__Unlock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
|
i->AddCall("EQW::GetPlayerCount", std::bind(EQW__GetPlayerCount, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
|
i->AddCall("EQW::GetZoneCount", std::bind(EQW__GetZoneCount, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
|
i->AddCall("EQW::GetLauncherCount", std::bind(EQW__GetLauncherCount, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
|
i->AddCall("EQW::GetLoginServerCount", std::bind(EQW__GetLoginServerCount, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
#include "../common/string_util.h"
|
#include "../common/string_util.h"
|
||||||
#include "../common/random.h"
|
#include "../common/random.h"
|
||||||
#include "../common/json/json.h"
|
#include "../common/json/json.h"
|
||||||
|
#include "../common/event_sub.h"
|
||||||
#include "web_interface.h"
|
#include "web_interface.h"
|
||||||
|
|
||||||
extern uint32 numzones;
|
extern uint32 numzones;
|
||||||
@ -657,7 +658,7 @@ void ZSList::SendLSZones(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ZSList::GetZoneCount() {
|
int ZSList::GetZoneCount() {
|
||||||
return(numzones);
|
return(list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZSList::GetZoneIDList(std::vector<uint32> &zones) {
|
void ZSList::GetZoneIDList(std::vector<uint32> &zones) {
|
||||||
@ -698,6 +699,10 @@ void ZSList::WorldShutDown(uint32 time, uint32 interval)
|
|||||||
|
|
||||||
void ZSList::OnTick(EQ::Timer *t)
|
void ZSList::OnTick(EQ::Timer *t)
|
||||||
{
|
{
|
||||||
|
if (!EventSubscriptionWatcher::Get()->IsSubscribed("EQW::ZoneUpdate")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value out;
|
Json::Value out;
|
||||||
out["event"] = "EQW::ZoneUpdate";
|
out["event"] = "EQW::ZoneUpdate";
|
||||||
out["data"] = Json::Value();
|
out["data"] = Json::Value();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user