Skip to content

Commit fd7d186

Browse files
committed
Fixed "onstreamended" issues. Fixed socket-reconnect issues.
1 parent 966573a commit fd7d186

File tree

8 files changed

+64
-52
lines changed

8 files changed

+64
-52
lines changed

RTCMultiConnection.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Last time updated: 2016-09-04 3:05:25 AM UTC
1+
// Last time updated: 2016-09-14 5:44:05 AM UTC
22

33
// _____________________
44
// RTCMultiConnection-v3
@@ -1272,20 +1272,21 @@
12721272
connectSocket(callback);
12731273
};
12741274

1275-
connection.socketAutoReConnect = true;
12761275
connection.closeSocket = function() {
12771276
try {
12781277
io.sockets = {};
12791278
} catch (e) {};
12801279

12811280
if (!connection.socket) return;
12821281

1283-
connection.socketAutoReConnect = false;
1284-
12851282
if (typeof connection.socket.disconnect === 'function') {
12861283
connection.socket.disconnect();
12871284
}
12881285

1286+
if (typeof connection.socket.resetProps === 'function') {
1287+
connection.socket.resetProps();
1288+
}
1289+
12891290
connection.socket = null;
12901291
};
12911292

@@ -1580,13 +1581,16 @@
15801581

15811582
var action = message.message.action;
15821583

1583-
if (action === 'ended' || action === 'stream-removed') {
1584+
if (action === 'ended' || action === 'inactive' || action === 'stream-removed') {
15841585
connection.onstreamended(stream);
15851586
return;
15861587
}
15871588

15881589
var type = message.message.type != 'both' ? message.message.type : null;
1589-
stream.stream[action](type);
1590+
1591+
if (typeof stream.stream[action] == 'function') {
1592+
stream.stream[action](type);
1593+
}
15901594
return;
15911595
}
15921596

@@ -1735,11 +1739,17 @@
17351739
});
17361740
});
17371741

1742+
var alreadyConnected = false;
1743+
1744+
connection.socket.resetProps = function() {
1745+
alreadyConnected = false;
1746+
};
1747+
17381748
connection.socket.on('connect', function() {
1739-
if (!connection.socketAutoReConnect) {
1740-
connection.socket = null;
1749+
if (alreadyConnected) {
17411750
return;
17421751
}
1752+
alreadyConnected = true;
17431753

17441754
if (connection.enableLogs) {
17451755
console.info('socket.io connection is opened.');
@@ -1755,14 +1765,8 @@
17551765
});
17561766

17571767
connection.socket.on('disconnect', function() {
1758-
if (!connection.socketAutoReConnect) {
1759-
connection.socket = null;
1760-
return;
1761-
}
1762-
17631768
if (connection.enableLogs) {
1764-
console.info('socket.io connection is closed');
1765-
console.warn('socket.io reconnecting');
1769+
console.warn('socket.io connection is closed');
17661770
}
17671771
});
17681772

RTCMultiConnection.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/RTCMultiConnection.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,20 +1256,21 @@ function RTCMultiConnection(roomid, forceOptions) {
12561256
connectSocket(callback);
12571257
};
12581258

1259-
connection.socketAutoReConnect = true;
12601259
connection.closeSocket = function() {
12611260
try {
12621261
io.sockets = {};
12631262
} catch (e) {};
12641263

12651264
if (!connection.socket) return;
12661265

1267-
connection.socketAutoReConnect = false;
1268-
12691266
if (typeof connection.socket.disconnect === 'function') {
12701267
connection.socket.disconnect();
12711268
}
12721269

1270+
if (typeof connection.socket.resetProps === 'function') {
1271+
connection.socket.resetProps();
1272+
}
1273+
12731274
connection.socket = null;
12741275
};
12751276

dev/SocketConnection.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ function SocketConnection(connection, connectCallback) {
5555

5656
var action = message.message.action;
5757

58-
if (action === 'ended' || action === 'stream-removed') {
58+
if (action === 'ended' || action === 'inactive' || action === 'stream-removed') {
5959
connection.onstreamended(stream);
6060
return;
6161
}
6262

6363
var type = message.message.type != 'both' ? message.message.type : null;
64-
stream.stream[action](type);
64+
65+
if (typeof stream.stream[action] == 'function') {
66+
stream.stream[action](type);
67+
}
6568
return;
6669
}
6770

@@ -210,11 +213,17 @@ function SocketConnection(connection, connectCallback) {
210213
});
211214
});
212215

216+
var alreadyConnected = false;
217+
218+
connection.socket.resetProps = function() {
219+
alreadyConnected = false;
220+
};
221+
213222
connection.socket.on('connect', function() {
214-
if (!connection.socketAutoReConnect) {
215-
connection.socket = null;
223+
if (alreadyConnected) {
216224
return;
217225
}
226+
alreadyConnected = true;
218227

219228
if (connection.enableLogs) {
220229
console.info('socket.io connection is opened.');
@@ -230,14 +239,8 @@ function SocketConnection(connection, connectCallback) {
230239
});
231240

232241
connection.socket.on('disconnect', function() {
233-
if (!connection.socketAutoReConnect) {
234-
connection.socket = null;
235-
return;
236-
}
237-
238242
if (connection.enableLogs) {
239-
console.info('socket.io connection is closed');
240-
console.warn('socket.io reconnecting');
243+
console.warn('socket.io connection is closed');
241244
}
242245
});
243246

dev/gumadapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// gumadapter.js => github.com/muaz-khan/gumadapter
44
// https://cdn.webrtc-experiment.com/gumadapter.js
55

6-
// getUserMedia hacks from git/webrtc/adapter;
6+
// getUserMedia hacks from git/webrtc/adapter;
77
// removed redundant codes
88
// A-to-Zee, all copyrights goes to:
99
// https://github.com/webrtc/adapter/blob/master/LICENSE.md

dist/rmc3.fbr.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rmc3.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Last time updated: 2016-09-04 3:05:25 AM UTC
1+
// Last time updated: 2016-09-14 5:44:05 AM UTC
22

33
// _____________________
44
// RTCMultiConnection-v3
@@ -1272,20 +1272,21 @@
12721272
connectSocket(callback);
12731273
};
12741274

1275-
connection.socketAutoReConnect = true;
12761275
connection.closeSocket = function() {
12771276
try {
12781277
io.sockets = {};
12791278
} catch (e) {};
12801279

12811280
if (!connection.socket) return;
12821281

1283-
connection.socketAutoReConnect = false;
1284-
12851282
if (typeof connection.socket.disconnect === 'function') {
12861283
connection.socket.disconnect();
12871284
}
12881285

1286+
if (typeof connection.socket.resetProps === 'function') {
1287+
connection.socket.resetProps();
1288+
}
1289+
12891290
connection.socket = null;
12901291
};
12911292

@@ -1580,13 +1581,16 @@
15801581

15811582
var action = message.message.action;
15821583

1583-
if (action === 'ended' || action === 'stream-removed') {
1584+
if (action === 'ended' || action === 'inactive' || action === 'stream-removed') {
15841585
connection.onstreamended(stream);
15851586
return;
15861587
}
15871588

15881589
var type = message.message.type != 'both' ? message.message.type : null;
1589-
stream.stream[action](type);
1590+
1591+
if (typeof stream.stream[action] == 'function') {
1592+
stream.stream[action](type);
1593+
}
15901594
return;
15911595
}
15921596

@@ -1735,11 +1739,17 @@
17351739
});
17361740
});
17371741

1742+
var alreadyConnected = false;
1743+
1744+
connection.socket.resetProps = function() {
1745+
alreadyConnected = false;
1746+
};
1747+
17381748
connection.socket.on('connect', function() {
1739-
if (!connection.socketAutoReConnect) {
1740-
connection.socket = null;
1749+
if (alreadyConnected) {
17411750
return;
17421751
}
1752+
alreadyConnected = true;
17431753

17441754
if (connection.enableLogs) {
17451755
console.info('socket.io connection is opened.');
@@ -1755,14 +1765,8 @@
17551765
});
17561766

17571767
connection.socket.on('disconnect', function() {
1758-
if (!connection.socketAutoReConnect) {
1759-
connection.socket = null;
1760-
return;
1761-
}
1762-
17631768
if (connection.enableLogs) {
1764-
console.info('socket.io connection is closed');
1765-
console.warn('socket.io reconnecting');
1769+
console.warn('socket.io connection is closed');
17661770
}
17671771
});
17681772

dist/rmc3.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)