-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (33 loc) · 947 Bytes
/
index.js
File metadata and controls
45 lines (33 loc) · 947 Bytes
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
41
42
43
44
45
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var User = function(id, name) {
this.x = 0;
this.y = 0;
this.id = id;
this.name = name;
};
var users = [];
app.use(express.static(__dirname + '/app'));
//console.log(__dirname + '/app' + 'asdsSDADASD');
//app.configure(function(){
//express.use('/media', express.static(__dirname + '/media'));
//app.use(express.static(__dirname + '/app'));
//});
//app.get('/', function(req, res){
// res.sendFile(__dirname + '/index.html');
//});
io.on('connection', function(socket){
socket.on('chat message', function(msg){
io.emit('chat message', msg);
});
socket.on('general:auth', function(name){
var user = new User(users.length, name);
users.push(user);
io.emit('general:authComplete', users);
});
});
http.listen(8080, function(){
console.log('listening on *:8080');
});