Giter Club home page Giter Club logo

datachannel-wasm's Introduction

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

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 LGPLv2, see LICENSE.

Installation

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

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

CMakeLists.txt:

[...]
add_subdirectory(deps/datachannel-wasm EXCLUDE_FROM_ALL)
target_link_libraries(YOUR_PROJECT datachannel-wasm)

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

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

CMakeLists.txt:

if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
    add_subdirectory(deps/datachannel-wasm EXCLUDE_FROM_ALL)
    target_link_libraries(YOUR_PROJECT datachannel-wasm)
else()
    option(NO_MEDIA "Disable media support in libdatachannel" ON)
    add_subdirectory(deps/libdatachannel EXCLUDE_FROM_ALL)
    target_link_libraries(YOUR_PROJECT datachannel-static)
endif()

Building

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

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

datachannel-wasm's People

Contributors

hanseuljun avatar paullouisageneau avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.