Skip to content

Commit

Permalink
Released version 1.3.1 with breaking new changes. Check readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Jan 10, 2019
1 parent 22fcaf2 commit c48fc95
Show file tree
Hide file tree
Showing 11 changed files with 362 additions and 385 deletions.
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,27 @@

[![npm](https://img.shields.io/npm/v/rtcmulticonnection-server.svg)](https://npmjs.org/package/rtcmulticonnection-server) [![downloads](https://img.shields.io/npm/dm/rtcmulticonnection-server.svg)](https://npmjs.org/package/rtcmulticonnection-server)

**Installation Guide:** https://github.com/muaz-khan/RTCMultiConnection-Server/wiki
> Since version `1.3.1`: now `rtcmulticonnection-server` does not creates any HTTP server.
>
> Now you need to use this: `require('rtcmulticonnection-server').addSocket(socket)` where `socket` is your socket.io connection object.
>
> It means that now you can integrate `rtcmulticonnection-server` inside any socket.io application or expressjsj/angular frameworks.
Free servers:
```sh
npm install rtcmulticonnection-server

# either
node server.js --help

# or
require('rtcmulticonnection-server').addSocket(socket);
```

**Installation Guide:**

* https://github.com/muaz-khan/RTCMultiConnection-Server/wiki

## Free socket.io servers

```javascript
connectin.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';
Expand All @@ -19,11 +37,22 @@ connectin.socketURL = 'https://webrtcweb.com:9002/';

## Integrate inside nodejs applications

```javascript
const ioServer = require('socket.io');
const RTCMultiConnectionServer = require('rtcmulticonnection-server');

ioServer(httpApp).on('connection', function(socket) {
RTCMultiConnectionServer.addSocket(socket);
});
```

For more information:

* https://github.com/muaz-khan/RTCMultiConnection-Server/wiki/Integrate-inside-nodejs-applications

## Demos

* https://github.com/muaz-khan/RTCMultiConnection
* https://rtcmulticonnection.herokuapp.com/demos/

## License

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rtcmulticonnection-server",
"description": "RTCMultiConnection socket.io server",
"version": "1.3.0",
"version": "1.3.1",
"authors": [
{
"name": "Muaz Khan",
Expand Down
15 changes: 8 additions & 7 deletions node_scripts/Scalable-Broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var pushLogs = require('./pushLogs.js');

var users = {};

module.exports = exports = function(root, socket, maxRelayLimitPerUser) {
module.exports = exports = function(config, socket, maxRelayLimitPerUser) {
try {
maxRelayLimitPerUser = parseInt(maxRelayLimitPerUser) || 2;
} catch (e) {
Expand Down Expand Up @@ -73,7 +73,7 @@ module.exports = exports = function(root, socket, maxRelayLimitPerUser) {
socket.emit('logs', 'You <' + user.userid + '> are now serving the broadcast.');
}
} catch (e) {
pushLogs(root, 'join-broadcast', e);
pushLogs(config, 'join-broadcast', e);
}
});

Expand All @@ -98,7 +98,7 @@ module.exports = exports = function(root, socket, maxRelayLimitPerUser) {
try {
callback(!!users[userid] && users[userid].isBroadcastInitiator === true);
} catch (e) {
pushLogs(root, 'check-broadcast-presence', e);
pushLogs(config, 'check-broadcast-presence', e);
}
});

Expand Down Expand Up @@ -193,7 +193,7 @@ module.exports = exports = function(root, socket, maxRelayLimitPerUser) {

delete users[socket.userid];
} catch (e) {
pushLogs(root, 'scalable-broadcast-disconnect', e);
pushLogs(config, 'scalable-broadcast-disconnect', e);
}
};

Expand Down Expand Up @@ -248,7 +248,7 @@ function askNestedUsersToRejoin(relayReceivers) {

});
} catch (e) {
pushLogs(root, 'askNestedUsersToRejoin', e);
pushLogs(config, 'askNestedUsersToRejoin', e);
}
}

Expand Down Expand Up @@ -278,7 +278,8 @@ function getFirstAvailableBroadcaster(broadcastId, maxRelayLimitPerUser) {
if (userFound) {
continue;
} else if (user.broadcastId === broadcastId) {
if (!user.relayReceivers.length && user.canRelay === true) {
// if (!user.relayReceivers.length && user.canRelay === true) {
if (user.relayReceivers.length < maxRelayLimitPerUser && user.canRelay === true) {
userFound = user;
}
}
Expand All @@ -292,6 +293,6 @@ function getFirstAvailableBroadcaster(broadcastId, maxRelayLimitPerUser) {
// so that each relaying user can distribute the bandwidth
return broadcastInitiator;
} catch (e) {
pushLogs(root, 'getFirstAvailableBroadcaster', e);
pushLogs(config, 'getFirstAvailableBroadcaster', e);
}
}
Loading

0 comments on commit c48fc95

Please sign in to comment.