Skip to content

Commit 8ffd1a2

Browse files
committed
configFile
1 parent 376a8bf commit 8ffd1a2

File tree

9 files changed

+41
-11
lines changed

9 files changed

+41
-11
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ cd web-minecraft
1818
#Instalacja niezbędnych bibliotek
1919
npm install
2020

21-
#Uruchamianie serwera i przeglądarki
21+
```
22+
23+
<h1>Uruchamianie gry</h1>
24+
25+
```bash
26+
27+
#Uruchamianie serwera express i websocket
2228
npm start
2329

2430
```
2531

32+
Po uruchomieniu serwera gra zostanie hostowana pod linkiem <a href="http://localhost:25565">http://localhost:25565</a>
33+
2634
<h1>Użyteczne narzędzia:</h1>
2735

2836
```bash

build/coffee/bundle.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ init = ()->
675675
#Socket.io setup
676676
(()->
677677
server=new Server {
678-
ip:"http://localhost:35565"
678+
ip:"#{al.get("host")}:#{al.get("websocket-port")}"
679679
terrain
680680
}
681681
server.onChunkUpdate (chunk)->

client/assets/assetLoader.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,13 @@
6363
"anvil":{
6464
"path":"assets/models/anvil/anvil.fbx",
6565
"type":"fbx"
66+
},
67+
"websocket-port":{
68+
"path":"/websocket/",
69+
"type":"text"
70+
},
71+
"host":{
72+
"path":"/host/",
73+
"type":"text"
6674
}
6775
}

client/bundle.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.

config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"websocket-port":35565,
3+
"express-port":8080,
4+
"host":"localhost"
5+
}

server/express.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
module.exports = function(port) {
1+
module.exports = function(config) {
2+
var port=config["express-port"]
23
const express = require('express');
34
const app = express();
45

@@ -7,7 +8,13 @@ module.exports = function(port) {
78
res.set('Cache-Control', 'no-store')
89
next()
910
})
11+
app.get("/websocket/",function (req,res){
12+
res.send(String(config["websocket-port"]))
13+
})
14+
app.get("/host/",function (req,res){
15+
res.send(String(config["host"]))
16+
})
1017
app.listen(port, () => {
11-
console.log(`Running: \x1b[35m\x1b[4mhttp://localhost:${port}\x1b[0m`);
18+
console.log(`Running: \x1b[35m\x1b[4mhttp://${config["host"]}:${port}\x1b[0m`);
1219
});
1320
}

server/savedWorld.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

server/websocket.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
module.exports = function(port) {
1+
module.exports = function(config) {
2+
var port=config["websocket-port"]
23
const http = require('http');
34
const fs = require('fs');
45

start.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
var opn = require('opn');
1+
const fs = require('fs');
22

3-
require("./server/websocket.js")(35565)
4-
require("./server/express.js")(25565)
3+
var rawdata = fs.readFileSync(__dirname+'/config.json');
4+
var config = JSON.parse(rawdata);
55

6-
opn(`http://localhost:25565`)
6+
require("./server/websocket.js")(config)
7+
require("./server/express.js")(config)

0 commit comments

Comments
 (0)