Real-Time Communication

Real-Time Communication in the Web, WebRTC in short, is a set of APIs allowing web applications to send and receive streaming real-time video, audio and data to/from remote peers, without relying it through the centralized server. The server, implementing one of the specific signalling protocols, is needed for initial discovery and connection handshake, though. The APIs rely on the mediaStream object - see Audio & Video Capture.

API glimpse

connection = new RTCPeerConnection(configuration)
Creates a connection object that will be used to establish serverless connection between peers. The configuration may include the set of iceServers that will be used for discovery and connection handshake.
connection.addEventListener('icecandidate', listener)
An event fired when the signalling server registers a remote peer with which the connection may be established.
Adds an existing local Media Stream (e.g. the local web cam) to the remote peer connection.
connection.onaddstream = event => video.src = URL.createObjectURL(
Registers an onaddstream event handler that, if and when called, retrieves the remote party's Media Stream and plugs it into a <video> tag video.
Returns a Promise resolved when the remote peer connects to the connections and streams offered.
Accepts the connection offerred by the remote peer. Returns a Promise resolved when the connection is established.
dataChannel = connection.createDataChannel(label, configuration)
Opens a data channel for the connection, allowing it to transmit arbitrary types of data.
Sends the data over the data channel to the remote peer.
dataChannel.addEventListener('message', listener)
An event fired when the data has been received via the data channel.