-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver
More file actions
32 lines (24 loc) · 719 Bytes
/
server
File metadata and controls
32 lines (24 loc) · 719 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
#!/usr/bin/env node
const config = require('../config.json');
const socket = require('socket.io');
let app = require('http').createServer();
let io = socket(app);
app.listen(config.game, () => {
console.log(`Husky Engine Game Server listening on ${config.game}`)
});
io.on('connection', (socket) => {
console.log(`Connection from ${socket.id}`);
io.emit('_connected', {})
// Handle events here //
// Ping event
socket.on('_ping', data => {
// Contains uuid
if (data.uuid) {
console.log(`User's uuid is ${data.uuid}`);
socket.uuid = data.uuid;
}
// Reply with same data
let reply = {data: data.data};
io.emit('_pong', reply);
});
});