BlueCam PHP Server Scripting

Note: Ensure that PHP and PostgreSQL are installed, your database tables exist and your configDB.php includes the proper connection config settings

Include BlueCam and Init API:

include "BlueCam/php/BlueCam.php";
$BlueCam = new BlueCamAPI();

Developer Responsibilites:

While there are a number of available functions in BlueCam.php, the only crucial function is createRoom(). The developer may also wish to call getRoom() or getRooms() to get call details and info such as duration of video calls



options=> Owner, visitor, roomName, roomDescription, roomId, userId
returns=> The roomId of the created room

$BlueCam->getRoom($roomId, $options)

Gets the room specified by the roomId

$BlueCam->closeRoom($roomId, $options)

For ending a video call. If $options["force"] is false or not set, closeRoom checks the Private Room database record associated with roomId to ensure the user’s userId is authorized to close the chat.
$options["force"] => Set to true for developers to shut a room down without either user id in their session. Importantly, it does not check user credentials so is for developer use only and should not be exposed to the public for security.


Allows developers to get rooms data from their database. The possible options are:
Owner: Only show rooms owned by this user Visitor: Only show rooms with this user as visitor InvolvedUser: Only show room with this user in any capacity
Tip: Many clients bill their users by video chat usage: to calculate how long a video chat lasted, look at the duration property of the result set

$BlueCam->getNewMessagesForUser($roomId, $userId)

Used to exchange data between users for PHP polling message. Messages sent with WebRTC and PubNub do not touch the PHP or database

$BlueCam->markMessagesReceived($userId, $messageIds)

For robust message delivery, it is important to keep trying until you receive the affirmative that yes, the messages have all been delivered. This method updates the database to tell it that certain messages have definitely reached their recipient (the user specified by userId)

$BlueCam->processMessage($roomId, $messageData, $from, $to)

When new messages are received by the server, this means that WebRTC peer to peer data and pubnub(if enabled) have failed. It is PHP’s job to shuffle the message data to the client. The server should call processMessage for all message received from either party which will insert the message into the BlueCamMessages database table to be retrieved directly by the recipient.
Creating a room in BlueCam is done with a single PHP command:
Simply pass the owner, visitor, and a roomId(a random ID will be generated if not provided)
$roomId = $BlueCam->CreateRoom(array(