Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Belchy06 committed Jul 7, 2022
2 parents 3d641a4 + 17ed689 commit b23cba0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# PixelStreamingInfrastructure
# The new home for the Pixel Streaming servers!
The Pixel Streaming servers and web frontend that was in `Samples/PixelStreaming/WebServers` is now here.

Repository providing reference implementations for the various pieces of infrastructure needed to support running a PixelStreaming application.
These pieces are examples of a SignallingWebServer, SFU (Single Forwarding Unit), and Matchmaker.
## Goals

© 2004-2022, Epic Games, Inc. All rights reserved. Unreal and its logo are Epic’s trademarks or registered trademarks in the US and elsewhere.
The goals of this repository are to:

- Increase the release cadence for the Pixel Streaming servers (to mitigate browser breaking changes sooner).
- Encourage easier contribution of these components by Unreal Engine licensees.
- Facilitate a more standard web release mechanism (e.g. NPM packages or similar... coming soon).
- Grant a permissive license to distribute and modify this code wherever you see fit (MIT licensed).

## Repository contents

Reference implementations for the various pieces needed to support a PixelStreaming application:
- SignallingWebServer (Cirrus)
- SFU (Single Forwarding Unit)
- Matchmaker


## Legal
© 2004-2022, Epic Games, Inc. Unreal and its logo are Epic’s trademarks or registered trademarks in the US and elsewhere.
17 changes: 15 additions & 2 deletions SignallingWebServer/cirrus.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const defaultConfig = {
HttpPort: 80,
HttpsPort: 443,
StreamerPort: 8888,
SFUPort: 8889
SFUPort: 8889,
MaxPlayerCount: -1
};

const argv = require('yargs').argv;
Expand Down Expand Up @@ -94,6 +95,7 @@ var matchmakerAddress = '127.0.0.1';
var matchmakerPort = 9999;
var matchmakerRetryInterval = 5;
var matchmakerKeepAliveInterval = 30;
var maxPlayerCount = -1;

var gameSessionId;
var userSessionId;
Expand Down Expand Up @@ -149,6 +151,10 @@ try {
if (typeof config.MatchmakerRetryInterval != 'undefined') {
matchmakerRetryInterval = config.MatchmakerRetryInterval;
}

if (typeof config.MaxPlayerCount != 'undefined') {
maxPlayerCount = config.MaxPlayerCount;
}
} catch (e) {
console.error(e);
process.exit(2);
Expand Down Expand Up @@ -523,6 +529,13 @@ playerServer.on('connection', function (ws, req) {
ws.send(JSON.stringify({ type: "warning", warning: "Even though ?preferSFU was specified, there is currently no SFU connected." }));
}

if(playerCount + 1 > maxPlayerCount && maxPlayerCount !== -1)
{
console.logColor(logging.Red, `new connection would exceed number of allowed concurrent connections. Max: ${maxPlayerCount}, Current ${playerCount}`);
ws.close(1013, `too many connections. max: ${maxPlayerCount}, current: ${playerCount}`);
return;
}

++playerCount;
let playerId = (++nextPlayerId).toString();
console.logColor(logging.Green, `player ${playerId} (${req.connection.remoteAddress}) connected`);
Expand Down Expand Up @@ -590,7 +603,7 @@ playerServer.on('connection', function (ws, req) {
sendPlayerDisconnectedToMatchmaker();
sendPlayersCount();
} catch(err) {
console.logColor(loggin.Red, `ERROR:: onPlayerDisconnected error: ${err.message}`);
console.logColor(logging.Red, `ERROR:: onPlayerDisconnected error: ${err.message}`);
}
}

Expand Down
3 changes: 2 additions & 1 deletion SignallingWebServer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"HttpPort": 80,
"HttpsPort": 443,
"StreamerPort": 8888,
"SFUPort": 8889
"SFUPort": 8889,
"MaxPlayerCount": -1
}

0 comments on commit b23cba0

Please sign in to comment.