-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (27 loc) · 979 Bytes
/
index.js
File metadata and controls
32 lines (27 loc) · 979 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
// Import packages
const express = require("express");
const socketIO = require("socket.io");
const path = require("path");
// Configuration
const PORT = process.env.PORT || 3000;
const INDEX = path.join(__dirname, 'index.html');
// Start server
const server = express()
.use((req, res) => res.sendFile(INDEX) )
.listen(PORT, () => console.log("Listening on localhost:" + PORT));
// Initiatlize SocketIO
const io = socketIO(server);
// Register "connection" events to the WebSocket
io.on("connection", function(socket) {
io.emit('connected to my app');
// Register "join" events, requested by a connected client
// socket.on("join", function (room) {
// // join channel provided by client
// socket.join(room)
// // Register "image" events, sent by the client
// socket.on("image", function(msg) {
// // Broadcast the "image" event to all other clients in the room
// socket.broadcast.to(room).emit("image", msg);
// });
// })
});