-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (29 loc) · 970 Bytes
/
index.js
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
var express = require('express');
var socket = require('socket.io');
var application = express();
var server = application.listen(5000, function () {
console.log('Your Server Is runing at http:/localhost:5000');
});
application.use(express.static('public_html'));
var sio = socket(server);
sio.on('connection', function (visitor) {
console.log('we have a new visitor as id=>', visitor.id);
visitor.on('message', function (data) {
sio.sockets.emit('new_msg', data);
});
visitor.on('fileMessage', function (data) {
sio.sockets.emit('fileMessage', data);
});
visitor.on('deletemessageid', function (data) {
sio.sockets.emit('new_deletemessageid', data);
});
visitor.on('borad', function (data) {
visitor.broadcast.emit('new_borad', data);
});
visitor.on('sharingId', function (data) {
visitor.broadcast.emit('sharingId', data);
});
visitor.on('sharingIdForimage', function (data) {
visitor.sockets.emit('sharingIdForimage', data);
});
});