Search by

jumphp / webrtc

davidnurdin

WebRTC for JumPHP games and apps: peer-to-peer data channels and screen video, the same PHP API in the browser (the page's RTCPeerConnection) and on the desktop (a GStreamer webrtcbin sidecar)

Package info

git.jumphp.net/jumphp/jumphp-webrtc.git

Homepage

Issues

Type:jumphp-extension

pkg:composer/jumphp/webrtc

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

v0.5.53.1 2026-11-13 14:57 UTC

This package is not auto-updated.

Last update: 2026-11-14 01:56:47 UTC


README

WebRTC for JumPHP games and apps: peer-to-peer connections from PHP, the same code in the browser and on the desktop. A JumPHP engine extension (docs/extensions.md): composer require jumphp/webrtc, nothing to wire.

public function __construct(private WebRtc $webrtc) {}                 // a scene

$peer = $this->webrtc->peer();
$peer->on('signal', fn (array $s) => $net->sendJson(250, $s));       // offer / answer / ICE: send them to the other side, any way you like
// ... when the other side's signal arrives:  $peer->signal($s);
$chat = $peer->channel('chat');                                       // reliable + ordered (a 'pos' channel: ordered: false, retransmits: 0 = like UDP)
$chat->on('message', fn (string $text) => $this->log[] = $text);
$chat->send('hello');
$peer->offer();                                                       // one side offers, the other answers by itself
  • Browser: the page's RTCPeerConnection (engine page module jumphp-webrtc.js, through the JsBridge).
  • Desktop: a native peer, GStreamer webrtcbin driven as a sidecar process (bin/webrtc-gst.py); runs with the computer's python3 + GStreamer, or in Docker (image built the first time). Linux for now.
  • Screen streaming (desktop, Linux X11): $peer->screen(['fps' => 60, 'kbps' => 8000]) sends the computer's screen as H.264 (GPU encoder: VA-API / NVENC, or x264 zero-latency) with an input data channel (mouse, wheel, keys, Unicode text, injected with XTest). The JumPHP IDE's Screen on a phone is built on it, with the viewer JumPHP Screen (https://jumphp.net/jumphp-screen).
  • Signaling::overNet($net, $peer, $otherPlayer): the signals through the multiplayer relay of a LobbyScene room, then peer to peer.

Documentation: doc/index.md, the sidecar protocol doc/sidecar.md, a tutorial doc/tutorial.md, samples doc/samples/ (LoopbackSample: two peers in one game; OnlineSample: two players meet on the relay then talk peer to peer). Example game: games/webrtc-demo.