Skip to content

Commit fdd5d91

Browse files
committed
add some code an bump version test
1 parent de31016 commit fdd5d91

3 files changed

Lines changed: 32 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "emulatorjs-netplay-server",
33
"productName": "EmulatorJS Netplay Server",
4-
"version": "0.3.9",
4+
"version": "0.4.0",
55
"main": "app.js",
66
"bin": "server.js",
77
"description": "A Netplay Server For EmulatorJS",

server.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ function startserver() {
3737
res.sendStatus(401)
3838
}
3939
});
40+
app.post('/status', (req, res) => {
41+
const reject = () => {
42+
res.setHeader('www-authenticate', 'Basic')
43+
res.sendStatus(401)
44+
}
45+
if (!checkAuth(req.headers.authorization, password)) {
46+
return reject();
47+
}
48+
res.end('{ "port": ' + port + ', "password": "' + password + '", "nofusers": ' + nofusers + ' }');
49+
});
4050
server.listen(port || 3000, '0.0.0.0', () => {
4151
consolelog("Starting server on port " + (port || 3000) + " with password " + password);
4252
if(appserver){

src/index.html

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,9 @@
108108
<div id="content" class="content">
109109
<h1>EmulatorJS Netplay Server</h1>
110110
<img src="img/logo-light.png" alt="Logo" class="logo">
111-
<h3>Server Info:</h3>
112-
<p>Runing on port: <b>3000</b></p>
113-
<p>Password is: <b>admin123</b></p>
111+
<p id="info">Server info</p>
114112
<h3>Server Options:</h3>
115113
<button onclick="startbutton()" id="server" class="button">Start Server</button>
116-
<button onclick="changeport()" id="port" class="button">Change Port</button>
117114
<p id="status"></p>
118115
<p id="nuser"></p>
119116
<br>
@@ -137,6 +134,26 @@ <h3>Server Options:</h3>
137134
}, 2000);
138135
});
139136

137+
(function() {
138+
status().then(info => {
139+
document.getElementById('info').innerHTML = "Running server on port " + (info.port || 3000) + " with password " + info.password;
140+
});
141+
document.getElementById('urls').innerHTML = '<li><a href="'+window.location.protocol+"//"+window.location.hostname+':'+window.location.port+'/" target="_blank" onclick="window.api.openExternal(this.href);event.preventDefault()">'+window.location.protocol+"//"+window.location.hostname+':'+window.location.port+'/</a></li>';
142+
})();
143+
144+
function status() {
145+
return fetch('/status', {
146+
method: 'POST',
147+
headers: {
148+
'Content-Type': 'application/json'
149+
}
150+
})
151+
.then(response => response.json())
152+
.then(data => {
153+
return data;
154+
});
155+
}
156+
140157
var startstop = document.getElementById('startStop');
141158
function startbutton(){
142159
if (startstop.textContent === 'Start'){
@@ -176,10 +193,6 @@ <h3>Server Options:</h3>
176193
update();
177194
});
178195
}
179-
(function() {
180-
check();
181-
document.getElementById('urls').innerHTML = '<li><a href="'+window.location.protocol+"//"+window.location.hostname+':'+window.location.port+'/" target="_blank" onclick="window.api.openExternal(this.href);event.preventDefault()">'+window.location.protocol+"//"+window.location.hostname+':'+window.location.port+'/</a></li>';
182-
})();
183196
function startstopserver(option){
184197
fetch('/startstop', {
185198
method: 'POST',

0 commit comments

Comments
 (0)