WebRTC is a Protocol specifically designed for Peer-To-Peer streaming of video + audio. It includes video/audio compression algorithms/codecs, key framing, session control, etc. It does offer some messaging but that part of the protocol doesn't work very well. As a Protocol, like ftp, http, smtp, etc., it requires support at a lower level than the Application tier in most cases. Currently, support for the WebRTC protocol is not on every device/operating system. Notably, Apple devices don't support WebRTC natively. You can see support here: http://iswebrtcreadyyet.com/ and http://caniuse.com/#feat=rtcpeerconnection. Since Apple doesn't support natively, an SDK for iOS is needed, there is an open source one, or you can go with a full service SaaS with an SDK. The upsides of WebRTC is that it is free, works pretty well, and handles automatic upgrading and downgrading of compression/quality based on latency. The downsides of WebRTC is that the standards are still evolving, changing, a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (request) => { | |
const kvstore = require('kvstore'); | |
const xhr = require('xhr'); | |
const vault = require('vault'); // You can use the Vault to store a header/key for your backend | |
// to validate the request with, alternatively you can use IP whitelist | |
const host = 'https://f8234c78.ngrok.io'; | |
var url = host + '/v1/webhooks/pubnub'; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function guid() { | |
function s4() { | |
return Math.floor((1 + Math.random()) * 0x10000) | |
.toString(16) | |
.substring(1); | |
} | |
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | |
s4() + '-' + s4() + s4() + s4(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (request) => { | |
const pubnub = require('pubnub'); | |
const kvstore = require('kvstore'); | |
const xhr = require('xhr'); | |
function crc32(str) { | |
function Utf8Encode(string) { | |
string = string.replace(/\r\n/g, "\n"); | |
var utftext = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function crc32(str) { | |
function Utf8Encode(string) { | |
string = string.replace(/\r\n/g, "\n"); | |
var utftext = ""; | |
for (var n = 0; n < string.length; n++) { | |
var c = string.charCodeAt(n); | |
if (c < 128) { |
- PubNub timetoken:
14459765691299403
- Divide by 10000000 (becomes Epoch in seconds if you truncate):
1445976569.1299403
- Subtract 1.0 seconds:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function normalize_subscribe_message_callback_object(msg, envelope) { | |
var result = { | |
channel_group: null, | |
channel: null, | |
message: msg | |
}; | |
// if the message received through channel group | |
if (envelope.length === 4) { | |
result.channel_group = envelope[2]; | |
result.channel = envelope[3]; |
Additional Reference: PubNub Github Repo README Instructions
Important Notes
Make sure that your iOS project (.xcodeproj) is within a Xcode Workspace (.xcworkspace). Being in a workspace rather than a project changes Xcode behavior when drag-dropping files.
If you are only in an .xcodeproj, then it doesn't prompt you with options to "copy items if needed" and automatically creates symlink rather than copy files into project (hence being susceptible to the changes in the original PubNub project).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Include the PubNub Library --> | |
<script src="https://cdn.pubnub.com/pubnub.min.js"></script> | |
<!-- Instantiate PubNub --> | |
<script type="text/javascript"> | |
var PUBNUB_demo = PUBNUB.init({ | |
publish_key: 'demo', | |
subscribe_key: 'demo' | |
}); |
NewerOlder