项目作者: paullouisageneau

项目描述 :
C++ WebRTC Data Channels for WebAssembly
高级语言: C++
项目地址: git://github.com/paullouisageneau/datachannel-wasm.git
创建时间: 2020-06-10T13:56:57Z
项目社区:https://github.com/paullouisageneau/datachannel-wasm

开源协议:GNU Lesser General Public License v2.1

下载


datachannel-wasm - C++ WebRTC Data Channels for WebAssembly in browsers

License: MIT Gitter Discord

datachannel-wasm is a C++ WebRTC Data Channels and WebSocket wrapper for Emscripten compatible with libdatachannel.

datachannel-wasm exposes the same API as libdatachannel, and therefore allows to compile the same C++ code using Data Channels and WebSockets to WebAssembly for browsers in addition to native targets supported by libdatachannel. The interface is only a subset of the one of libdatachannel, in particular, tracks and media transport are not supported. See what is available in wasm/include.

These wrappers were originally written for my multiplayer game Convergence and were extracted from there to be easily reusable.

datachannel-wasm is licensed under MIT, see LICENSE.

Installation

You just need to add datachannel-wasm as a submodule in your Emscripten project:

  1. $ git submodule add https://github.com/paullouisageneau/datachannel-wasm.git deps/datachannel-wasm
  2. $ git submodule update --init --recursive

CMakeLists.txt:

  1. [...]
  2. add_subdirectory(deps/datachannel-wasm EXCLUDE_FROM_ALL)
  3. target_link_libraries(YOUR_TARGET datachannel-wasm)

Since datachannel-wasm is compatible with libdatachannel, you can easily leverage both to make the same C++ code compile to native (including Apple macOS and Microsoft Windows):

  1. $ git submodule add https://github.com/paullouisageneau/datachannel-wasm.git deps/datachannel-wasm
  2. $ git submodule add https://github.com/paullouisageneau/libdatachannel.git deps/libdatachannel
  3. $ git submodule update --init --recursive --depth 1

CMakeLists.txt:

  1. if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
  2. add_subdirectory(deps/datachannel-wasm EXCLUDE_FROM_ALL)
  3. target_link_libraries(YOUR_TARGET datachannel-wasm)
  4. else()
  5. option(NO_MEDIA "Disable media support in libdatachannel" ON)
  6. add_subdirectory(deps/libdatachannel EXCLUDE_FROM_ALL)
  7. target_link_libraries(YOUR_TARGET datachannel)
  8. endif()

Building

Building requires that you have emsdk installed and activated in your environment:

  1. $ cmake -B build -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
  2. $ cd build
  3. $ make -j2