-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (28 loc) · 1002 Bytes
/
Copy pathindex.js
File metadata and controls
36 lines (28 loc) · 1002 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
var express = require('express');
var socket = require('socket.io');
// App setup
var app = express();
var server = app.listen(4200, function(){
console.log('listening for requests on port 4200,');
});
// Static files
app.use(express.static('website'));
// Socket setup
var io = socket(server);
// Listen for new connection and print a message in console
io.on('connection', (socket) => {
console.log('made socket connection', socket.id);
// Listening for chat event
socket.on('chat', function(data){
console.log('chat event trigged at server');
console.log('need to notify all the clients about this event');
//io.sockets.emit('chat', data);
});
// Listening for typing event
socket.on('typing', function(data){
console.log('Server received someone is typing');
console.log('need to inform all the clients about this');
//io.sockets.emit('typing', data);
//socket.broadcast.emit('typing', data);
});
});