mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
WebSocketServer: Move enums to types
directory
Code cleanup, makes WebSocketServer match how enums are handled in other parts of the plugin
This commit is contained in:
parent
959347337f
commit
0a294a558e
@ -127,6 +127,8 @@ set(obs-websocket_HEADERS
|
||||
src/Config.h
|
||||
src/WebSocketApi.h
|
||||
src/websocketserver/WebSocketServer.h
|
||||
src/websocketserver/types/WebSocketCloseCode.h
|
||||
src/websocketserver/types/WebSocketOpCode.h
|
||||
src/websocketserver/rpc/WebSocketSession.h
|
||||
src/eventhandler/EventHandler.h
|
||||
src/eventhandler/types/EventSubscription.h
|
||||
|
@ -27,6 +27,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
#include <websocketpp/server.hpp>
|
||||
|
||||
#include "rpc/WebSocketSession.h"
|
||||
#include "types/WebSocketCloseCode.h"
|
||||
#include "types/WebSocketOpCode.h"
|
||||
#include "../utils/Json.h"
|
||||
#include "../requesthandler/rpc/Request.h"
|
||||
#include "../plugin-macros.generated.h"
|
||||
@ -50,35 +52,6 @@ class WebSocketServer : QObject
|
||||
bool isIdentified;
|
||||
};
|
||||
|
||||
enum WebSocketCloseCode {
|
||||
// Internal only
|
||||
DontClose = 0,
|
||||
// Reserved
|
||||
UnknownReason = 4000,
|
||||
// The server was unable to decode the incoming websocket message
|
||||
MessageDecodeError = 4002,
|
||||
// A data key is missing but required
|
||||
MissingDataKey = 4003,
|
||||
// A data key has an invalid type
|
||||
InvalidDataKeyType = 4004,
|
||||
// The specified `op` was invalid or missing
|
||||
UnknownOpCode = 4005,
|
||||
// The client sent a websocket message without first sending `Identify` message
|
||||
NotIdentified = 4006,
|
||||
// The client sent an `Identify` message while already identified
|
||||
AlreadyIdentified = 4007,
|
||||
// The authentication attempt (via `Identify`) failed
|
||||
AuthenticationFailed = 4008,
|
||||
// The server detected the usage of an old version of the obs-websocket RPC protocol.
|
||||
UnsupportedRpcVersion = 4009,
|
||||
// The websocket session has been invalidated by the obs-websocket server.
|
||||
SessionInvalidated = 4010,
|
||||
// A data key's value is invalid, in the case of things like enums.
|
||||
InvalidDataKeyValue = 4011,
|
||||
// A feature is not supported because of hardware/software limitations.
|
||||
UnsupportedFeature = 4012,
|
||||
};
|
||||
|
||||
WebSocketServer();
|
||||
~WebSocketServer();
|
||||
|
||||
@ -107,7 +80,7 @@ class WebSocketServer : QObject
|
||||
|
||||
private:
|
||||
struct ProcessResult {
|
||||
WebSocketCloseCode closeCode = WebSocketCloseCode::DontClose;
|
||||
WebSocketCloseCode::WebSocketCloseCode closeCode = WebSocketCloseCode::DontClose;
|
||||
std::string closeReason;
|
||||
json result;
|
||||
};
|
||||
|
@ -28,20 +28,6 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
#include "../utils/Platform.h"
|
||||
#include "../utils/Compat.h"
|
||||
|
||||
namespace WebSocketOpCode {
|
||||
enum WebSocketOpCode: uint8_t {
|
||||
Hello = 0,
|
||||
Identify = 1,
|
||||
Identified = 2,
|
||||
Reidentify = 3,
|
||||
Event = 5,
|
||||
Request = 6,
|
||||
RequestResponse = 7,
|
||||
RequestBatch = 8,
|
||||
RequestBatchResponse = 9,
|
||||
};
|
||||
}
|
||||
|
||||
bool IsSupportedRpcVersion(uint8_t requestedVersion)
|
||||
{
|
||||
return (requestedVersion == 1);
|
||||
|
51
src/websocketserver/types/WebSocketCloseCode.h
Normal file
51
src/websocketserver/types/WebSocketCloseCode.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2021 Stephane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2020-2021 Kyle Manning <tt2468@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace WebSocketCloseCode {
|
||||
enum WebSocketCloseCode {
|
||||
// Internal only
|
||||
DontClose = 0,
|
||||
// Reserved
|
||||
UnknownReason = 4000,
|
||||
// The server was unable to decode the incoming websocket message
|
||||
MessageDecodeError = 4002,
|
||||
// A data key is missing but required
|
||||
MissingDataKey = 4003,
|
||||
// A data key has an invalid type
|
||||
InvalidDataKeyType = 4004,
|
||||
// The specified `op` was invalid or missing
|
||||
UnknownOpCode = 4005,
|
||||
// The client sent a websocket message without first sending `Identify` message
|
||||
NotIdentified = 4006,
|
||||
// The client sent an `Identify` message while already identified
|
||||
AlreadyIdentified = 4007,
|
||||
// The authentication attempt (via `Identify`) failed
|
||||
AuthenticationFailed = 4008,
|
||||
// The server detected the usage of an old version of the obs-websocket RPC protocol.
|
||||
UnsupportedRpcVersion = 4009,
|
||||
// The websocket session has been invalidated by the obs-websocket server.
|
||||
SessionInvalidated = 4010,
|
||||
// A data key's value is invalid, in the case of things like enums.
|
||||
InvalidDataKeyValue = 4011,
|
||||
// A feature is not supported because of hardware/software limitations.
|
||||
UnsupportedFeature = 4012,
|
||||
};
|
||||
}
|
34
src/websocketserver/types/WebSocketOpCode.h
Normal file
34
src/websocketserver/types/WebSocketOpCode.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2021 Stephane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2020-2021 Kyle Manning <tt2468@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace WebSocketOpCode {
|
||||
enum WebSocketOpCode: uint8_t {
|
||||
Hello = 0,
|
||||
Identify = 1,
|
||||
Identified = 2,
|
||||
Reidentify = 3,
|
||||
Event = 5,
|
||||
Request = 6,
|
||||
RequestResponse = 7,
|
||||
RequestBatch = 8,
|
||||
RequestBatchResponse = 9,
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user