mirror of
https://github.com/exane/not-gwent-online
synced 2024-11-20 11:26:54 +00:00
use node http server
This commit is contained in:
parent
e0c4d9705c
commit
a0ad60d21b
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
node_modules
|
||||
.idea
|
||||
public/
|
||||
!public/Config.js
|
||||
public
|
||||
test/spec
|
||||
assets/cards/*
|
||||
client/scss/_cards.scss
|
||||
|
@ -1,16 +0,0 @@
|
||||
|
||||
window.Config = {};
|
||||
|
||||
Config.Server = {
|
||||
"hostname": "192.168.123.1",
|
||||
"port": 16918,
|
||||
secure: false
|
||||
}
|
||||
|
||||
Config.Gwent = {
|
||||
notification_duration: 4000
|
||||
}
|
||||
|
||||
Config.Site = {
|
||||
base: "/gwent-online/site/public"
|
||||
}
|
11
README.md
11
README.md
@ -7,12 +7,10 @@ Not-Gwent-Online is a standalone multiplayer version of Gwent, a card game from
|
||||
##- Requirements
|
||||
- [node.js](https://nodejs.org/) installed
|
||||
- [GraphicsMagick](http://www.graphicsmagick.org) installed (for generating sprites)
|
||||
- Any Webserver like xampp, wamp, lamp etc
|
||||
|
||||
##- Build
|
||||
Make sure to clone the project in your webserver root folder, otherwise you won't be able to access your client later.
|
||||
The root folder is often called 'www' or 'htdocs', but depends on your installed webserver.
|
||||
```git
|
||||
|
||||
```sh
|
||||
cd ~/myWebserverRoot
|
||||
git clone https://github.com/exane/not-gwent-online
|
||||
cd not-gwent-online
|
||||
@ -24,13 +22,12 @@ npm run build
|
||||
##- Config
|
||||
- go to /public and open Config.js
|
||||
- change hostname to your address. (e.g., "192.168.123.1") <br>Make sure you don't have a trailing slash after your IP or address. (e.g., "192.168.123.1/")
|
||||
- If you have to change the port then make sure you change the port on your server as well. <br>You find the server port in /server/server.js on line #18 "app.listen(#port)";
|
||||
|
||||
##- Start Server
|
||||
```
|
||||
```sh
|
||||
cd ~/myProjectDirectory/not-gwent-online
|
||||
node server/server.js
|
||||
```
|
||||
|
||||
##- Start Client
|
||||
- Open your browser and go to "192.168.123.1/not-gwent-online/public" or wherever you saved your project.
|
||||
- Open your browser and go to e.g. "http://192.168.123.1:4000"
|
@ -5,7 +5,7 @@
|
||||
"main": "gulpfile.js",
|
||||
"dependencies": {
|
||||
"connect": "3.0.1",
|
||||
"express": "4.12.3",
|
||||
"express": "^4.13.4",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"jquery-deferred": "^0.3.0",
|
||||
"minimist": "1.1.0",
|
||||
|
@ -1,16 +1,32 @@
|
||||
|
||||
window.Config = {};
|
||||
var Config = {};
|
||||
|
||||
Config.Server = {
|
||||
"hostname": "localhost",
|
||||
"port": 16918,
|
||||
secure: false
|
||||
}
|
||||
"hostname": "127.0.0.1",
|
||||
"port": 16918
|
||||
};
|
||||
|
||||
Config.WebServer = {
|
||||
"port": 3000
|
||||
};
|
||||
|
||||
Config.Gwent = {
|
||||
notification_duration: 4000
|
||||
}
|
||||
};
|
||||
|
||||
Config.Site = {
|
||||
base: "/gwent/site/public"
|
||||
(function (name, definition){
|
||||
if (typeof define === 'function'){ // AMD
|
||||
define(definition);
|
||||
} else if (typeof module !== 'undefined' && module.exports) { // Node.js
|
||||
module.exports = definition();
|
||||
} else { // Browser
|
||||
var theModule = definition(), global = this, old = global[name];
|
||||
theModule.noConflict = function () {
|
||||
global[name] = old;
|
||||
return theModule;
|
||||
};
|
||||
global[name] = theModule;
|
||||
}
|
||||
})('Config', function () {
|
||||
return Config;
|
||||
});
|
@ -1,5 +1,8 @@
|
||||
var argv = require('minimist')(process.argv.slice(2));
|
||||
|
||||
var http = require("http");
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
var Config = require("../public/Config")
|
||||
|
||||
global.connections = require("./Connections")();
|
||||
|
||||
@ -9,17 +12,18 @@ global.Room = require("./Room");
|
||||
|
||||
global.User = require("./User");
|
||||
|
||||
/*global.Socket = require("./Socket");*/
|
||||
var server = http.createServer(app);
|
||||
global.io = require("socket.io").listen(server);
|
||||
server.listen(Config.Server.port);
|
||||
|
||||
app.use(express.static('public'));
|
||||
app.use('/public', express.static('public'));
|
||||
app.use('/assets', express.static('assets'));
|
||||
|
||||
var app = require('http').createServer();
|
||||
global.io = require("socket.io")(app);
|
||||
|
||||
app.listen(16918);
|
||||
app.listen(Config.WebServer.port);
|
||||
|
||||
var admin = io.of("/admin");
|
||||
|
||||
|
||||
io.on("connection", function(socket) { //global connection
|
||||
var user;
|
||||
connections.add(user = User(socket));
|
||||
|
Loading…
Reference in New Issue
Block a user