Skip to content
Snippets Groups Projects
Commit 390bdccc authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Merge branch 'feature/#57' into 'main'

#57 Add new URI schemes

See merge request beyondaka/beyond-protocol!35
parents f00b1180 0d4385e0
No related branches found
No related tags found
No related merge requests found
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
\ No newline at end of file
......@@ -66,8 +66,12 @@ class URI {
SCHEME_IPC,
SCHEME_FILE,
SCHEME_OTHER,
SCHEME_DEVICE,
SCHEME_GROUP
SCHEME_DEVICE, // Data source
SCHEME_GROUP,
SCHEME_CAST, // Broadcaster stream
SCHEME_MUX, // Multiplexer for streams
SCHEME_MIRROR, // Proxy for streams
SCHEME_BEYOND // Settings
};
/**
......
......@@ -8,6 +8,8 @@
#include <ftl/protocol/self.hpp>
#include "./streams/netstream.hpp"
#include "./streams/filestream.hpp"
#include <ftl/protocol/muxer.hpp>
#include <ftl/protocol/broadcaster.hpp>
#include <ftl/lib/nlohmann/json.hpp>
#include "uuidMSGPACK.hpp"
......@@ -31,6 +33,8 @@ std::shared_ptr<ftl::protocol::Stream> Self::createStream(const std::string &uri
case ftl::URI::SCHEME_FTL : return std::make_shared<ftl::protocol::Net>(uri, universe_.get(), true);
case ftl::URI::SCHEME_FILE :
case ftl::URI::SCHEME_NONE : return std::make_shared<ftl::protocol::File>(uri, true);
case ftl::URI::SCHEME_CAST : return std::make_shared<ftl::protocol::Broadcast>();
case ftl::URI::SCHEME_MUX : return std::make_shared<ftl::protocol::Muxer>();
default : throw FTL_Error("Invalid Stream URI: " << uri);
}
}
......
......@@ -27,6 +27,23 @@ using ftl::URI;
using ftl::uri_t;
using std::string;
static const std::unordered_map<std::string, ftl::URI::scheme_t> schemeMap = {
{"tcp", URI::SCHEME_TCP},
{"udp", URI::SCHEME_UDP},
{"ws", URI::SCHEME_WS},
{"wss", URI::SCHEME_WSS},
{"ftl", URI::SCHEME_FTL},
{"http", URI::SCHEME_HTTP},
{"ipc", URI::SCHEME_IPC},
{"device", URI::SCHEME_DEVICE},
{"file", URI::SCHEME_FILE},
{"group", URI::SCHEME_GROUP},
{"beyond", URI::SCHEME_TCP},
{"mux", URI::SCHEME_MUX},
{"mirror", URI::SCHEME_MIRROR},
{"cast", URI::SCHEME_CAST}
};
URI::URI(uri_t puri) {
_parse(puri);
}
......@@ -105,18 +122,16 @@ void URI::_parse(uri_t puri) {
m_host = std::string(uri.hostText.first, uri.hostText.afterLast - uri.hostText.first);
std::string prototext = std::string(uri.scheme.first, uri.scheme.afterLast - uri.scheme.first);
if (prototext == "tcp") m_proto = SCHEME_TCP;
else if (prototext == "udp") m_proto = SCHEME_UDP;
else if (prototext == "ftl") m_proto = SCHEME_FTL;
else if (prototext == "http") m_proto = SCHEME_HTTP;
else if (prototext == "ws") m_proto = SCHEME_WS;
else if (prototext == "wss") m_proto = SCHEME_WSS;
else if (prototext == "ipc") m_proto = SCHEME_IPC;
else if (prototext == "device") m_proto = SCHEME_DEVICE;
else if (prototext == "file") m_proto = SCHEME_FILE;
else if (prototext == "group") m_proto = SCHEME_GROUP;
else
m_proto = SCHEME_OTHER;
if (prototext == "") {
m_proto = SCHEME_FILE;
} else {
auto protoIt = schemeMap.find(prototext);
if (protoIt == schemeMap.end()) {
m_proto = SCHEME_OTHER;
} else {
m_proto = protoIt->second;
}
}
m_protostr = prototext;
std::string porttext = std::string(uri.portText.first, uri.portText.afterLast - uri.portText.first);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment