-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit.js
More file actions
46 lines (32 loc) · 1012 Bytes
/
Copy pathinit.js
File metadata and controls
46 lines (32 loc) · 1012 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
46
//import express and instantiate it
var express = require('express');
var app = express();
//create a new http server that pipes to the express instance
var http = require('http').Server(app);
//require socketio and create a socket.io server bound to the existing http server
var io = require('socket.io')(http);
app.use(express.static(__dirname + '/public'));
http.listen(8080,function(){
console.log("Running server on port 8080...");
});
io.on('connection',function(socket){
console.log("user connected to socket!");
socket.on('clear-console',function(data){
console.log(data);
});
socket.on('new-message',function(data){
console.log("new message event triggered!");
console.log("new-message data:");
console.log(data);
socket.emit('new-message',data);
});
});
/*
app.post('/', function(req, res){
console.log("POST request received!");
//console.log("req: ");
//console.log(req);
//need to write response
//res.sendFile(__dirname + '/public' + '/index.html');
});
*/