-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (23 loc) · 746 Bytes
/
app.js
File metadata and controls
29 lines (23 loc) · 746 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
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.use(express.static('public'));
//app.get('/', function(req, res){
// res.sendFile(__dirname+"/index.html");
//});
io.on("connection", function(client){
client.emit("annoucement", "Hello to Chat!");
client.on("message", function(data){
client.emit("message", data);
client.broadcast.emit("message", data);
});
client.on('drawing-mousemoving', function (data) {
if(data.drawing)
console.log("user drawing");
client.broadcast.emit('drawing-moving', data);
});
});
http.listen(8080, function(){
console.log("Node server running.");
});