PeerJS server - gd-99/symbiogd GitHub Wiki

A PeerJS server implementation in PHP is currently in development in Symbiose. The PeerJS server runs alongside the WebSocket server, on the same port. The server runs with Ratchet, a WebSocket library for PHP.

PeerJS implementation

This implementation is based on the original PeerJS server : https://github.com/peers/peerjs-server. You can see the source code on the branch feat-empathy.

The WebSocket server code is in /lib/PeerServer.class.php and the HTTP server is in /lib/PeerHttpServer.class.php.

Some features are not implemented yet, such as HTTP streaming.

Server-to-server communication

PeerJS server-to-server communication

In order to allow two users connected on two different servers to talk, the PeerJS server implementation supports server-to-server communication.

By example, a user Bob is connected on webos.example.com and wants to talk with Alice on the server webos.symbiose.fr.cr. Bob can start a new chat session with [email protected]:9000/peerjs, assuming 9000 is the port on which the WebSocket server runs.

Peer address

A peer address is written peerId[@server[:port][/path][#appName]]:

  • peerId: the peer ID
  • @server (optionnal): the server hostname
  • :port (optionnal): the server port
  • /path (optionnal): the server path
  • #appName (optionnal): the application name

Multiple peers

This feature is not implemented for now.

The problem of WebRTC is for chats & calls with a large number of peers. The solution is to implement a p2p-like data sharing: everyone downloads and uploads simultaneously.