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

Commit

Permalink
Merge pull request #211 from kasp1/master
Browse files Browse the repository at this point in the history
New matchmaker queue screen with easy customization
  • Loading branch information
mcottontensor committed Aug 31, 2023
2 parents 19438d8 + 22489b6 commit 6b742d3
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 16 deletions.
1 change: 1 addition & 0 deletions Matchmaker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
html/custom/
10 changes: 10 additions & 0 deletions Matchmaker/Docs/Customizing the Queue UI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Customizing the Queue UI

The Matchmaker server allows for custom HTML UI to be displayed. In order to create a custom queue UI template:

1. Duplicate the `Matchmaker/html/sample` directory as `Matchmaker/html/custom`.
2. Edit `Matchmaker/html/custom/queue/queue.html` as needed.

It is required to keep the same directory struture and file names for the template (`.html`) files. The Matchmaker server will prefer the `custom` directory over `sample`. The `custom` directory always needs to contain all templates from the `sample` directory.

The `custom` directory can contain additional files, which may be referenced in the template files with a path relative to `Matchmaker/html/custom`. For example, an image located as `Matchmaker/html/custom/images/1.png` could be referenced as `<img src="/images/1.png" alt="">` in a template (`.html`) file.
12 changes: 12 additions & 0 deletions Matchmaker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Pixel Streaming Matchmaker

Instead of having all users connect to the same stream, you may want each person to end up in their own interactive experiences. To do this, you can run a separate stack of Pixel Streaming components for each user, and direct each user to a separate Signaling and Web Server to start a connection.

You can set up each stack of Pixel Streaming components on a separate host, or you can put more than one stack on the same host as long as you configure the port settings for the components within each stack so that they all communicate over different ports. See the Pixel Streaming Reference for details on these port settings.

To help set up this kind of configuration, the Pixel Streaming system can use a **matchmaker** server that tracks which Signaling and Web Servers are available, and whether they are being used by a client connection.


## Docs
- [Hosting and Networking Guide](https://docs.unrealengine.com/5.1/en-US/hosting-and-networking-guide-for-pixel-streaming-in-unreal-engine/)
- [Customizing the Queue UI](Docs/Customizing%20the%20Queue%20UI.md)
3 changes: 2 additions & 1 deletion Matchmaker/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"HttpPort": 90,
"UseHTTPS": false,
"MatchmakerPort": 9999,
"LogToFile": true
"LogToFile": true,
"EnableWebserver": true
}
Binary file added Matchmaker/html/sample/images/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Matchmaker/html/sample/images/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Matchmaker/html/sample/images/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Matchmaker/html/sample/images/favicon.ico
Binary file not shown.
Binary file added Matchmaker/html/sample/images/ue-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions Matchmaker/html/sample/queue/queue.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Looking for a streaming host...</title>
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon">
<link rel="icon" type="image/png" sizes="96x96" href="/images/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Michroma&family=Montserrat:wght@600&display=swap" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="queue/styles.css">
</head>
<body>
<main>
<section>
<img id="logo" src="images/ue-logo.png" alt="Unreal Engine">
<h1>All Streaming Hosts Busy</h1>
<p>Please wait,</p>
<p>checking all ${cirrusServers.size} hosts again in <span id="countdown">3</span> seconds.</p>
</section>
</main>

<script type="text/javascript">
var countdown = document.getElementById("countdown").textContent;
setInterval(function() {
countdown--;
if (countdown == 0) {
window.location.reload(1);
} else {
document.getElementById("countdown").textContent = countdown;
}
}, 1000);
</script>
</body>
</html>
33 changes: 33 additions & 0 deletions Matchmaker/html/sample/queue/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
* { box-sizing: border-box; }

body {
background-color: black;
color: white;
font-family: 'Montserrat', sans-serif;
margin: 0;
}

main {
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
}

section {
text-align: center;
}

h1 {
font-size: 1.8em;
text-transform: uppercase;
}

p {
text-align: center;
}

#logo {
display: inline-block;
height: 20vh;
}
34 changes: 21 additions & 13 deletions Matchmaker/matchmaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const defaultConfig = {
MatchmakerPort: 9999,

// Log to file
LogToFile: true
LogToFile: true,

EnableWebserver: true,
};

// Similar to the Signaling Server (SS) code, load in a config.json file for the MM parameters
Expand Down Expand Up @@ -86,21 +88,27 @@ if (config.UseHTTPS) {
});
}

let htmlDirectory = 'html/sample'
if(config.EnableWebserver) {
// Setup folders

if (fs.existsSync('html/custom')) {
app.use(express.static(path.join(__dirname, '/html/custom')))
htmlDirectory = 'html/custom'
} else {
app.use(express.static(path.join(__dirname, '/html/sample')))
}
}

// No servers are available so send some simple JavaScript to the client to make
// it retry after a short period of time.
function sendRetryResponse(res) {
res.send(`All ${cirrusServers.size} Cirrus servers are in use. Retrying in <span id="countdown">3</span> seconds.
<script>
var countdown = document.getElementById("countdown").textContent;
setInterval(function() {
countdown--;
if (countdown == 0) {
window.location.reload(1);
} else {
document.getElementById("countdown").textContent = countdown;
}
}, 1000);
</script>`);
// find check if a custom template should be used or the sample one
let html = fs.readFileSync(`${htmlDirectory}/queue/queue.html`, { encoding: 'utf8' })
html = html.replace(/\$\{cirrusServers\.size\}/gm, cirrusServers.size)

res.setHeader('content-type', 'text/html')
res.send(html)
}

// Get a Cirrus server if there is one available which has no clients connected.
Expand Down
4 changes: 2 additions & 2 deletions Matchmaker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6b742d3

Please sign in to comment.