-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
socket.js
53 lines (44 loc) · 1.39 KB
/
socket.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const webSocker = require('./app').io
module.exports = {
socketEvents: (io = webSocker) => {
let count = 0
io.on('connection', function (socket) {
console.log('Socket conn count: ' + count++)
io.emit('user connected')
socket.on('test', (data) => {
console.log('test invoked')
io.emit('test response', { data: data })
})
// PROJECT RELATED NOTIFICATIONS
socket.on('new project added', (data) => {
console.log('New project data ->', data)
io.emit('new project', { data: data })
})
// EVENTS RELATED NOTIFICATIONS
socket.on('new event addeed', (data) => {
io.emit('new event', { data: data })
})
// POST RELATED NOTIFICATIONS
socket.on('create post event', (data) => {
console.log('create post event invoked')
io.emit('new post', {
data: data
})
})
// INTERNET RELATED ISSUE NOTIFICATIONS
socket.on('internet issue emit', (data) => {
console.log('Internet issue in ')
io.emit('internet issue', { data: data })
})
socket.on('internet issue resolved emit', (data) => {
io.emit('internet issue resolved', { data: data })
})
socket.on('disconnect', function () {
io.emit('user disconnected')
})
socket.on('test', () => {
io.emit('test response')
})
})
}
}