Skip to content

Commit a04947e

Browse files
committed
Fixed a few bugs. All chats back to working
1 parent a32f86a commit a04947e

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

js/rtc-controller.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
var CONTROLLER = window.CONTROLLER = function(phone){
55
if (!window.phone) window.phone = phone;
66
var ctrlChan = controlChannel(phone.number());
7-
var isStream = phone.oneway;
87
var pubnub = phone.pubnub;
98
var userArray = [];
109
subscribe();
@@ -95,7 +94,7 @@ var CONTROLLER = window.CONTROLLER = function(phone){
9594
}
9695

9796
CONTROLLER.send = function( message, number ) {
98-
if (isStream) return stream_message(message);
97+
if (phone.oneway) return stream_message(message);
9998
phone.send(message, number);
10099
};
101100

@@ -174,7 +173,8 @@ var CONTROLLER = window.CONTROLLER = function(phone){
174173
if (idx != -1) userArray.splice(idx, 1)[0]; // User leaving
175174
} else { // New User added to stream/group
176175
if (idx == -1) { // Tell everyone in array of new user first, then add to array.
177-
if (!isStream) publishCtrlAll("userJoin", session.number);
176+
alert(phone.oneway);
177+
if (!phone.oneway) publishCtrlAll("userJoin", session.number);
178178
userArray.push(session);
179179
}
180180
}
@@ -222,7 +222,7 @@ var CONTROLLER = window.CONTROLLER = function(phone){
222222
callAuth(m.data);
223223
break;
224224
case "userJoin":
225-
if (isStream) add_to_stream(m.data); // JOIN STREAM HERE!
225+
if (phone.oneway){ alert("HERE"); add_to_stream(m.data); }// JOIN STREAM HERE!
226226
else add_to_group(m.data);
227227
break;
228228
case "userLeave":

js/webrtc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ var PHONE = window.PHONE = function(config) {
1616
var myconnection = false;
1717
var mediaconf = config.media || { audio : true, video : true };
1818
var conversations = {};
19-
var oneway = config.oneway || false;
19+
var oneway = config.oneway || false
20+
var broadcast = config.broadcast || false;
2021

2122
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
2223
// RTC Peer Connection Session (one per call)
@@ -190,8 +191,7 @@ var PHONE = window.PHONE = function(config) {
190191

191192
// Add Local Media Streams Audio Video Mic Camera
192193
// If answering and oneway streaming, do not attach stream
193-
if (!isAnswer || !oneway)
194-
talk.pc.addStream(mystream); // Add null here on the receiving end of streaming to go one-way.
194+
if (!isAnswer || !oneway) talk.pc.addStream(mystream); // Add null here on the receiving end of streaming to go one-way.
195195

196196
// Notify of Call Status
197197
update_conversation( talk, 'connecting' );
@@ -415,7 +415,7 @@ var PHONE = window.PHONE = function(config) {
415415
// Prepare Local Media Camera and Mic
416416
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
417417
function getusermedia() { //Do something if not requesting any media?
418-
if (oneway){
418+
if (oneway && !broadcast){
419419
if (!PeerConnection){ return unablecb(); }
420420
onready();
421421
subscribe();

streams.html renamed to stream.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
number : streamName, // listen on username line else random
8585
publish_key : 'pub-c-561a7378-fa06-4c50-a331-5c0056d0163c', // Your Pub Key
8686
subscribe_key : 'sub-c-17b7db8a-3915-11e4-9868-02ee2ddab7fe', // Your Sub Key
87-
oneway : true
87+
oneway : true,
88+
broadcast : true
8889
});
8990
phone.debug(function(m){ console.log(m); })
9091
var ctrl = window.ctrl = CONTROLLER(phone);

0 commit comments

Comments
 (0)