libdatachannel
Standalone WebRTC Data Channels, WebRTC Media Transport, and WebSockets
Wraps a native library — check OS Compatibility below for platform-specific linking notes.
Summary
| Latest Version | 0.1.0 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:27 |
Tags
Authors
- OpenPeeps
Installation
nimble install libdatachannel
choosenim install libdatachannel
git clone https://github.com/openpeeps/libdatachannel-nim
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| libdatachannel | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.0.0 | No |
Source
| Repository | https://github.com/openpeeps/libdatachannel-nim |
|---|---|
| Homepage | https://github.com/openpeeps/libdatachannel-nim |
| Registry Source | nimble_official |
README
Nim language 👑 bindings for Libdatachannel
A standalone WebRTC Data Channels, WebRTC Media Transport, and WebSockets
nimble install libdatachannel
😍 Key Features
- [x] Lightweight WebRTC Data Channel/Media Transport
-
[x] Fast Server/Client WebSockets
-
[x] High-level API in Nim style!
- [x] Low-level bindings
libdatachannel
Build the library
First, you will need to build libdatachannel from GitHub source. See Building instructions
Examples
WebSocket Example
WebSocket Server This is a simple WebSocket server that listens for incoming connections and echoes back any messages it receives.
from std/os implement sleep
import libdatachannel/websockets
proc connectionCallback(wsserver: cint, ws: cint, userPtr: pointer) {.cdecl.} =
proc wsMessageCallback(ws: cint, msg: cstring, size: cint, userPtr: pointer) =
echo "Message from client ", $msg
ws.message(msg) # echo the message back
discard rtcSetMessageCallback(ws, wsMessageCallback)
# send a welcome message
ws.message("Welcome to WebSocket Server!")
let wss = newWebSocketServer(port = Port(1234))
wss.startServer(connectionCallback)
while true:
sleep(1000)
WebSocket Client
from std/os implement sleep
import libdatachannel/websockets
let client = newWebSocketClient("ws://127.0.0.1:1234")
client.listen(onMessage) do(ws: cint, message: cstring, size: cint, userPtr: pointer):
echo $message
sleep(500)
while true:
wsclient.send("Hello from client!")
sleep(1000)
Peer Connection
todo
❤ Contributions & Support
- 🐛 Found a bug? Create a new Issue
- 👋 Wanna help? Fork it!
- 😎 Get €20 in cloud credits from Hetzner
🎩 License
MIT license. Made by Humans from OpenPeeps.
Copyright © 2025 OpenPeeps & Contributors — All rights reserved.