-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathioHandlers.js
More file actions
34 lines (30 loc) · 1.23 KB
/
ioHandlers.js
File metadata and controls
34 lines (30 loc) · 1.23 KB
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
const OSC = require('osc-js');
const osc = require('./osc').osc
module.exports = (io) => {
io.on('connection', (client) => {
console.log('Connection succeeded', client.id)
client.on('disconnect', () => {
console.log('Client disconnected', client.id)
const message = new OSC.Message('/dynscore/leave', client.id);
osc.send(message)
})
client.on('create', (room) => {
client.join(room);
const message = new OSC.Message('/dynscore/join', client.id, room);
osc.send(message)
})
/*
client.on('switch room', (previousRoom, newRoom) => {
client.leave(previousRoom, () => {
// use io.to() to target users within a specific room
client.to(previousRoom).emit('user left room', client.id)
console.log('user left room ', client.id)
client.join(newRoom, () => {
client.to(newRoom).emit('user joined room', client.id)
console.log('user joined room ', client.id)
})
})
})
*/
})
}