Protocol: update GetVersion with list of available request types

This commit is contained in:
Stéphane L 2017-08-06 00:09:44 +02:00
parent c7190cb94a
commit 61931c179f
3 changed files with 17 additions and 3 deletions

View File

@ -342,6 +342,7 @@ __Response__ : always OK, with these additional fields :
- **"version"** (double) : OBSRemote API version. Fixed to 1.1 for retrocompatibility.
- **"obs-websocket-version"** (string) : obs-websocket version string
- **"obs-studio-version"** (string) : OBS Studio version string
- **"available-requests"** (string) : comma-separated list of available request types
---

View File

@ -18,12 +18,16 @@ with this program. If not, see <https://www.gnu.org/licenses/>
*/
#include <obs-data.h>
#include "WSRequestHandler.h"
#include <QList>
#include <QString>
#include "WSEvents.h"
#include "obs-websocket.h"
#include "Config.h"
#include "Utils.h"
#include <qstring.h>
#include "WSRequestHandler.h"
bool str_valid(const char* str) {
return (str != nullptr && strlen(str) > 0);
@ -192,13 +196,21 @@ bool WSRequestHandler::hasField(const char* name) {
void WSRequestHandler::HandleGetVersion(WSRequestHandler* req) {
const char* obs_version = Utils::OBSVersionString();
QList<QString> names = req->messageMap.keys();
names.sort(Qt::CaseInsensitive);
QString requests;
requests += names.takeFirst();
for (QString reqName : names) {
requests += ("," + reqName);
}
obs_data_t* data = obs_data_create();
obs_data_set_double(data, "version", API_VERSION);
obs_data_set_string(data, "obs-websocket-version", OBS_WEBSOCKET_VERSION);
obs_data_set_string(data, "obs-studio-version", obs_version);
obs_data_set_string(data, "available-requests", requests.toUtf8().constData());
req->SendOKResponse(data);
obs_data_release(data);
bfree((void*)obs_version);
}

View File

@ -20,6 +20,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#ifndef WSREQUESTHANDLER_H
#define WSREQUESTHANDLER_H
#include <QMap>
#include <QWebSocket>
#include <QWebSocketServer>