Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Longhouse-Games/guerrilla-checkers
...
head fork: Longhouse-Games/guerrilla-checkers
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
35 server.js → app.js
@@ -20,15 +20,11 @@ requirejs.config({
}
});
-var liferay = require('./server/liferay');
-
requirejs(['underscore', 'moment', './lib/checkers', './server/server.js'], function(_, moment, Checkers, Server) {
// global variables
-var portNumber = 3000;
var connectedUsers = 0;
-
// global types
var Schema = mongoose.Schema;
var ChatSchema = new Schema({
@@ -117,12 +113,6 @@ serve_dir = function(req, res) {
res.sendfile(__dirname + req.originalUrl);
}
-app.get('/white_draughts_man.png', function(req, res) {
- sendfile(__dirname + '/white_draughts_man.png');
-});
-app.get('/board.css', function(req, res) {
- sendfile(__dirname + '/board.css');
-});
app.post('/', function (req, res) {
handleLogin(req, res);
});
@@ -138,25 +128,7 @@ app.get('/lib/*', serve_dir);
app.get('/client/*', serve_dir);
app.get('/scripts/*', serve_dir);
-// TODO Refactor: base it more smartly on player ID and previous sessions
-// (so they can resume a game they've been disconnected from)
-function chooseRole(magic_number) {
- switch(magic_number % 2) {
- case 0:
- return 'guerrilla';
- case 1:
- return 'coin';
- default:
- return 'spectator';
- }
-};
-
-// initialize server
-mongoose.connect('mongodb://localhost/lvg');
-app.listen(portNumber);
-
// successful connection
-
io.set('authorization', function (data, accept) {
// check if there's a cookie header
if (data.headers.cookie) {
@@ -223,7 +195,12 @@ io.sockets.on('connection', function (socket) {
console.log('connected users: ', totalUsers());
});
-console.log("Server Started at localhost:"+portNumber);
+mongoose.connect('mongodb://localhost/lvg');
+
+var port = process.env.PORT || 3000;
+app.listen(port, function() {
+ console.log("Guerrilla-checkers listening on http://localhost:" + port);
+});
}); // requirejs Checkers
View
37 server/liferay.js
@@ -1,37 +0,0 @@
-
-var http = require('http')
- , querystring = require('querystring');
-
-exports.sendMessage = function(postData, callback) {
-
- // default arguments
- callback = callback || function(chunk) {};
- postData = postData || {};
-
- // build query
- var postDataString = querystring.stringify(postData);
- var postOptions = {
- host: 'localhost',
- port: '4000',
- path: '/',
- method: 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Content-Length': postDataString.length
- }
- };
-
- // set up the request
- var postRequest = http.request(postOptions, function(res) {
- res.setEncoding('utf8');
- res.on('data', callback);
- });
- postRequest.on('error', function(e) {
- console.log('failed to contact liferay server.');
- });
-
- // post the data
- postRequest.write(postDataString);
- postRequest.end();
-
-};
View
BIN  white_draughts_man.png
Deleted file not rendered

No commit comments for this range

Something went wrong with that request. Please try again.