Skip to content

Commit

Permalink
Updating cordova-apps links: http://webrtcweb.com:9001/cordova-apps/
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Oct 25, 2016
1 parent 15dd531 commit 246cd50
Show file tree
Hide file tree
Showing 3 changed files with 246 additions and 4 deletions.
234 changes: 234 additions & 0 deletions dev/BluetoothConnection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
function BluetoothConnection(connection, connectCallback) {
var channelId = connection.channel;

connection.socket = {};

function onBluetoothSignalingMessageCallback(data) {
data = JSON.parse(data);

if (data.eventName === connection.socketMessageEvent) {
onMessagesCallback(data.data);
}

if (data.eventName === 'presence') {
data = data.data;
if (data.userid === connection.userid) return;
connection.onUserStatusChanged({
userid: data.userid,
status: data.isOnline === true ? 'online' : 'offline',
extra: connection.peers[data.userid] ? connection.peers[data.userid].extra : {}
});
}
}

function sendUsingBluetooth(data) {
// send data using bluetooth
}

connection.socket.emit = function(eventName, data, callback) {
if (eventName === 'changed-uuid') return;
if (data.message && data.message.shiftedModerationControl) return;

sendUsingBluetooth(JSON.stringify({
eventName: eventName,
data: data
}));

if (callback) {
callback();
}
};

connection.socket.onerror = function() {
if (!connection.enableLogs) return;
console.error('Socket connection is failed.');
};

connection.socket.onclose = function() {
if (!connection.enableLogs) return;
console.warn('Socket connection is closed.');
};

connection.socket.onopen = function() {
if (connection.enableLogs) {
console.info('PubNub connection is opened.');
}

connection.socket.emit('presence', {
userid: connection.userid,
isOnline: true
});

if (connectCallback) connectCallback(connection.socket);
};

connection.socket.onopen();

var mPeer = connection.multiPeersHandler;

function onMessagesCallback(message) {
if (message.remoteUserId != connection.userid) return;

if (connection.peers[message.sender] && connection.peers[message.sender].extra != message.message.extra) {
connection.peers[message.sender].extra = message.message.extra;
connection.onExtraDataUpdated({
userid: message.sender,
extra: message.message.extra
});
}

if (message.message.streamSyncNeeded && connection.peers[message.sender]) {
var stream = connection.streamEvents[message.message.streamid];
if (!stream || !stream.stream) {
return;
}

var action = message.message.action;

if (action === 'ended' || action === 'stream-removed') {
connection.onstreamended(stream);
return;
}

var type = message.message.type != 'both' ? message.message.type : null;
stream.stream[action](type);
return;
}

if (message.message === 'connectWithAllParticipants') {
if (connection.broadcasters.indexOf(message.sender) === -1) {
connection.broadcasters.push(message.sender);
}

mPeer.onNegotiationNeeded({
allParticipants: connection.getAllParticipants(message.sender)
}, message.sender);
return;
}

if (message.message === 'removeFromBroadcastersList') {
if (connection.broadcasters.indexOf(message.sender) !== -1) {
delete connection.broadcasters[connection.broadcasters.indexOf(message.sender)];
connection.broadcasters = removeNullEntries(connection.broadcasters);
}
return;
}

if (message.message === 'dropPeerConnection') {
connection.deletePeer(message.sender);
return;
}

if (message.message.allParticipants) {
if (message.message.allParticipants.indexOf(message.sender) === -1) {
message.message.allParticipants.push(message.sender);
}

message.message.allParticipants.forEach(function(participant) {
mPeer[!connection.peers[participant] ? 'createNewPeer' : 'renegotiatePeer'](participant, {
localPeerSdpConstraints: {
OfferToReceiveAudio: connection.sdpConstraints.mandatory.OfferToReceiveAudio,
OfferToReceiveVideo: connection.sdpConstraints.mandatory.OfferToReceiveVideo
},
remotePeerSdpConstraints: {
OfferToReceiveAudio: connection.session.oneway ? !!connection.session.audio : connection.sdpConstraints.mandatory.OfferToReceiveAudio,
OfferToReceiveVideo: connection.session.oneway ? !!connection.session.video || !!connection.session.screen : connection.sdpConstraints.mandatory.OfferToReceiveVideo
},
isOneWay: !!connection.session.oneway || connection.direction === 'one-way',
isDataOnly: isData(connection.session)
});
});
return;
}

if (message.message.newParticipant) {
if (message.message.newParticipant == connection.userid) return;
if (!!connection.peers[message.message.newParticipant]) return;

mPeer.createNewPeer(message.message.newParticipant, message.message.userPreferences || {
localPeerSdpConstraints: {
OfferToReceiveAudio: connection.sdpConstraints.mandatory.OfferToReceiveAudio,
OfferToReceiveVideo: connection.sdpConstraints.mandatory.OfferToReceiveVideo
},
remotePeerSdpConstraints: {
OfferToReceiveAudio: connection.session.oneway ? !!connection.session.audio : connection.sdpConstraints.mandatory.OfferToReceiveAudio,
OfferToReceiveVideo: connection.session.oneway ? !!connection.session.video || !!connection.session.screen : connection.sdpConstraints.mandatory.OfferToReceiveVideo
},
isOneWay: !!connection.session.oneway || connection.direction === 'one-way',
isDataOnly: isData(connection.session)
});
return;
}

if (message.message.readyForOffer || message.message.addMeAsBroadcaster) {
connection.addNewBroadcaster(message.sender);
}

if (message.message.newParticipationRequest && message.sender !== connection.userid) {
if (connection.peers[message.sender]) {
connection.deletePeer(message.sender);
}

var userPreferences = {
extra: message.message.extra || {},
localPeerSdpConstraints: message.message.remotePeerSdpConstraints || {
OfferToReceiveAudio: connection.sdpConstraints.mandatory.OfferToReceiveAudio,
OfferToReceiveVideo: connection.sdpConstraints.mandatory.OfferToReceiveVideo
},
remotePeerSdpConstraints: message.message.localPeerSdpConstraints || {
OfferToReceiveAudio: connection.session.oneway ? !!connection.session.audio : connection.sdpConstraints.mandatory.OfferToReceiveAudio,
OfferToReceiveVideo: connection.session.oneway ? !!connection.session.video || !!connection.session.screen : connection.sdpConstraints.mandatory.OfferToReceiveVideo
},
isOneWay: typeof message.message.isOneWay !== 'undefined' ? message.message.isOneWay : !!connection.session.oneway || connection.direction === 'one-way',
isDataOnly: typeof message.message.isDataOnly !== 'undefined' ? message.message.isDataOnly : isData(connection.session),
dontGetRemoteStream: typeof message.message.isOneWay !== 'undefined' ? message.message.isOneWay : !!connection.session.oneway || connection.direction === 'one-way',
dontAttachLocalStream: !!message.message.dontGetRemoteStream,
connectionDescription: message,
successCallback: function() {
// if its oneway----- todo: THIS SEEMS NOT IMPORTANT.
if (typeof message.message.isOneWay !== 'undefined' ? message.message.isOneWay : !!connection.session.oneway || connection.direction === 'one-way') {
connection.addNewBroadcaster(message.sender, userPreferences);
}

if (!!connection.session.oneway || connection.direction === 'one-way' || isData(connection.session)) {
connection.addNewBroadcaster(message.sender, userPreferences);
}
}
};

connection.onNewParticipant(message.sender, userPreferences);
return;
}

if (message.message.shiftedModerationControl) {
connection.onShiftedModerationControl(message.sender, message.message.broadcasters);
return;
}

if (message.message.changedUUID) {
if (connection.peers[message.message.oldUUID]) {
connection.peers[message.message.newUUID] = connection.peers[message.message.oldUUID];
delete connection.peers[message.message.oldUUID];
}
}

if (message.message.userLeft) {
mPeer.onUserLeft(message.sender);

if (!!message.message.autoCloseEntireSession) {
connection.leave();
}

return;
}

mPeer.addNegotiatedMessage(message.message, message.sender);
}

window.addEventListener('beforeunload', function() {
connection.socket.emit('presence', {
userid: connection.userid,
isOnline: false
});
}, false);
}
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
* [How to implement client-side (local) screen-sharing without involving any 3rd-party service or extension or addon](/~https://github.com/muaz-khan/RTCMultiConnection/wiki/Screen-Sharing-on-your-Local-Server)
* [Detect Who is Speaking](/~https://github.com/muaz-khan/RTCMultiConnection/wiki/Detect-Who-is-Speaking)

# iOS+Android Demo Apps

* http://webrtcweb.com:9001/cordova-apps/

## Twitter

* https://twitter.com/WebRTCWeb i.e. @WebRTCWeb
Expand Down
12 changes: 8 additions & 4 deletions docs/ios-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ Please check these docs instead:
# Cordova Demos

Please check all iOS+Android demos here:

* http://webrtcweb.com:9001/cordova-apps/

| DemoTitle | DownloadZip | AndroidAPK | AllFiles |
| ------------- |-------------|-------------|-------------|
| Scalable Broadcast | [Source](http://dl.webrtc-experiment.com/cordova-apps/scalable-broadcast/Download-Source.zip) | [Android APK](http://dl.webrtc-experiment.com/cordova-apps/scalable-broadcast/Install-Android-App.apk) | [All files](http://dl.webrtc-experiment.com/cordova-apps/scalable-broadcast) |
| Audio Conferencing | [Source](http://dl.webrtc-experiment.com/cordova-apps/audio-conferencing/Download-Source.zip) | [Android APK](http://dl.webrtc-experiment.com/cordova-apps/audio-conferencing/Install-Android-App.apk) | [All files](http://dl.webrtc-experiment.com/cordova-apps/audio-conferencing) |
| Video Conferencing | [Source](http://dl.webrtc-experiment.com/cordova-apps/video-conferencing/Download-Source.zip) | [Android APK](http://dl.webrtc-experiment.com/cordova-apps/video-conferencing/Install-Android-App.apk) | [All files](http://dl.webrtc-experiment.com/cordova-apps/video-conferencing) |
| File Sharing | [Source](http://dl.webrtc-experiment.com/cordova-apps/filesharing/Download-Source.zip) | [Android APK](http://dl.webrtc-experiment.com/cordova-apps/filesharing/Install-Android-App.apk) | [All files](http://dl.webrtc-experiment.com/cordova-apps/filesharing) |
| Scalable Broadcast | [Source](http://webrtcweb.com:9001/cordova-apps/scalable-broadcast/Download-Source.zip) | [Android APK](http://webrtcweb.com:9001/cordova-apps/scalable-broadcast/Install-Android-App.apk) | [All files](http://webrtcweb.com:9001/cordova-apps/scalable-broadcast) |
| Audio Conferencing | [Source](http://webrtcweb.com:9001/cordova-apps/audio-conferencing/Download-Source.zip) | [Android APK](http://webrtcweb.com:9001/cordova-apps/audio-conferencing/Install-Android-App.apk) | [All files](http://webrtcweb.com:9001/cordova-apps/audio-conferencing) |
| Video Conferencing | [Source](http://webrtcweb.com:9001/cordova-apps/video-conferencing/Download-Source.zip) | [Android APK](http://webrtcweb.com:9001/cordova-apps/video-conferencing/Install-Android-App.apk) | [All files](http://webrtcweb.com:9001/cordova-apps/video-conferencing) |
| File Sharing | [Source](http://webrtcweb.com:9001/cordova-apps/filesharing/Download-Source.zip) | [Android APK](http://webrtcweb.com:9001/cordova-apps/filesharing/Install-Android-App.apk) | [All files](http://webrtcweb.com:9001/cordova-apps/filesharing) |

# Prerequisites

Expand Down

0 comments on commit 246cd50

Please sign in to comment.