-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (32 loc) · 1.03 KB
/
server.js
File metadata and controls
40 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// # SimpleServer
//
// A simple chat server using Socket.IO, Express, and Async.
//
//https://words.bighugelabs.com/api.php
var http = require('http');
var path = require('path');
var test = require('./external/external.js')
var async = require('async');
var socketio = require('socket.io');
var express = require('express');
//
// ## SimpleServer `SimpleServer(obj)`
//
// Creates a new instance of SimpleServer with the following options:
// * `port` - The HTTP port to listen on. If `process.env.PORT` is set, _it overrides this value_.
//
var router = express();
var server = http.createServer(router);
var io = socketio.listen(server);
router.use(express.static(path.resolve(__dirname, 'client')));
io.on('connection', function (socket) {
console.log("connected");
socket.on('disconnect', function () {
console.log("disconnected");
});
});
server.listen(process.env.PORT || 3000, process.env.IP || "0.0.0.0", function(){
var addr = server.address();
console.log("Instedit running on ", addr.address + ":" + addr.port);
});