BlueCam Realtime Data Exchange

Central Database vs Peer-to-Peer

Central databases are great and we hope you have a couple benefiting humanity. That said, server scripts and databases are just tools, and some features are notoriously difficult for PHP programmers to implement such as instant push delivery to the users browser from the server (and other users). Regular polling is often the best option but there is still a tradeoff between the frequency of the client polling the server and the timeliness of the message delivery.
Luckily for us, we are free men and women- we are not bound to one technology and are free to compliment our great tools with others as they arise and gain support.


An interesting new Javascript approach called WebRTC is creating new ways for browsers to “talk” to each other in real time. If you’re using BlueCam to connect two of your users for real time video/ audio chat, then you already have everything you need to send all kinds of JSON data between the users almost instantly.

Sending Messages Peer-to-Peer

The easiest, most robust method for sending data to the other user(let’s call her Person B) is calling sendMessage from the Javascript of Person A’s browser:

sendMessage(type, data)

After you’ve connected users in a BlueCam private room, sending data in real time between the users is as easy as calling: sendMessage. BlueCam takes care of delivering messages and prioritizes to use the fastest method, WebRTC.
sendMessage Examples:
sendMessage(“changedDrawing”, {“circles”:[], “rectangles”:[], “triangles”:[], “bgColor”:”blue”});
sendMessage(“shareLink”, “”);

Receiving Peer-to-Peer Messages

Make sure to handle by implementing the property “onMessage” on the BlueCam JS JoinCall method:
	//Other options
	onMessage: function(type, data) {
		if(type == "changedDrawing") {
		} else if(type == “shareLink”) {
			alert("The other user shared a link:" + data);
The possibilities are endless

Data Exchange Scheme/ Options:

  1. Top Option: WebRTC RTCPeerConnection/ RTCDataChannel
  2. Fast Optional Method: PubNub
  3. Fallback: BlueCam PHP Message Exchange