WebRTC for JumPHP: peer-to-peer data channels and screen video from PHP (read-only split of extensions/webrtc of JumPHP)
  • PHP 53.1%
  • Python 45%
  • Dockerfile 1.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
David Nurdin 96dbb7441f webrtc-demo: the example game of jumphp/webrtc, playable online in 14 languages
Two peers on one screen (PING / PONG with the round trip, a cursor over an unreliable channel) and a star-catching duel
peer to peer, against a bot (a second WebRTC peer of the game) or online (LobbyScene, signals through the relay).
Own menu (keys, mouse, touch), TTF fonts with Noto Sans subsets for ja / zh / ko, a simulated backend where WebRTC is
missing (headless tests), game tests, a site in 14 languages, thumbnail and icon.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 15:57:01 +01:00
bin JumPHP IDE 0.1.114: Screen on a phone (the computer's screen in a phone's browser, WebRTC) + the engine extension jumphp/webrtc 2026-11-13 07:19:13 +01:00
doc webrtc-demo: the example game of jumphp/webrtc, playable online in 14 languages 2026-11-13 15:57:01 +01:00
docker JumPHP IDE 0.1.114: Screen on a phone (the computer's screen in a phone's browser, WebRTC) + the engine extension jumphp/webrtc 2026-11-13 07:19:13 +01:00
src JumPHP IDE 0.1.114: Screen on a phone (the computer's screen in a phone's browser, WebRTC) + the engine extension jumphp/webrtc 2026-11-13 07:19:13 +01:00
composer.json JumPHP 0.5.53: engine/web/jumphp-webrtc.js in the shared engine (jumphp/webrtc in the browser); jumphp/webrtc on Packagist (split jumphp/jumphp-webrtc) 2026-11-13 08:00:39 +01:00
LICENSE JumPHP IDE 0.1.114: Screen on a phone (the computer's screen in a phone's browser, WebRTC) + the engine extension jumphp/webrtc 2026-11-13 07:19:13 +01:00
README.md JumPHP IDE 0.1.114: Screen on a phone (the computer's screen in a phone's browser, WebRTC) + the engine extension jumphp/webrtc 2026-11-13 07:19:13 +01:00

jumphp/webrtc

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.