Identifying users

In a typical web application, the server will need a way to identify between connected clients. Most applications today use the one-identity rule and have each user login to a respective string-based identifier known as their username. We will also be using the same rule in our signaling application. It will not be as sophisticated as some of the methods used today since we will not even require a password from the user. We simply need an ID for each connection so we know where to send messages.

To start, we are going to change our connection handler a bit, to look similar to this:

connection.on(''message'', function (message) { var data; try { data = JSON.parse(message); } catch (e) { console.log(""Error parsing JSON""); data ...

Get Learning WebRTC now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.