mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-23 15:48:03 +00:00
Fixed client build
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
project (libdatachannel
|
project(libdatachannel
|
||||||
DESCRIPTION "WebRTC DataChannels Library"
|
DESCRIPTION "WebRTC DataChannels Library"
|
||||||
VERSION 0.4.9
|
VERSION 0.4.9
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
@ -73,17 +73,6 @@ set(TESTS_SOURCES
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/test/capi.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test/capi.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TESTS_OFFERER_SOURCES
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test/p2p/offerer.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(TESTS_ANSWERER_SOURCES
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test/p2p/answerer.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
|
||||||
add_subdirectory(deps/json)
|
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
@ -193,3 +182,8 @@ set_target_properties(datachannel-tests PROPERTIES OUTPUT_NAME tests)
|
|||||||
target_include_directories(datachannel-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
target_include_directories(datachannel-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
target_link_libraries(datachannel-tests datachannel nlohmann_json::nlohmann_json)
|
target_link_libraries(datachannel-tests datachannel nlohmann_json::nlohmann_json)
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||||
|
add_subdirectory(deps/json)
|
||||||
|
add_subdirectory(examples/client)
|
||||||
|
|
||||||
|
7
examples/client/CMakeLists.txt
Normal file
7
examples/client/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
cmake_policy(SET CMP0079 NEW)
|
||||||
|
|
||||||
|
add_executable(datachannel-client main.cpp)
|
||||||
|
set_target_properties(datachannel-client PROPERTIES CXX_STANDARD 17)
|
||||||
|
target_link_libraries(datachannel-client datachannel nlohmann_json)
|
||||||
|
|
@ -51,9 +51,9 @@ int main(int argc, char **argv) {
|
|||||||
ws->onMessage([wpc = make_weak_ptr(pc)](const std::variant<binary, string> &data) {
|
ws->onMessage([wpc = make_weak_ptr(pc)](const std::variant<binary, string> &data) {
|
||||||
auto pc = wpc.lock();
|
auto pc = wpc.lock();
|
||||||
if (pc && holds_alternative<string>(data)) {
|
if (pc && holds_alternative<string>(data)) {
|
||||||
json message = json::parse(data.get<string>());
|
json message = json::parse(get<string>(data));
|
||||||
if (auto it = message.find("type")) {
|
if (auto it = message.find("type"); it != message.end()) {
|
||||||
auto type = it->second.get<string>();
|
auto type = it->get<string>();
|
||||||
if (type == "offer" || type == "answer") {
|
if (type == "offer" || type == "answer") {
|
||||||
auto str = message["description"].get<string>();
|
auto str = message["description"].get<string>();
|
||||||
pc->setRemoteDescription(Description(str, type));
|
pc->setRemoteDescription(Description(str, type));
|
||||||
|
Reference in New Issue
Block a user