-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (28 loc) · 806 Bytes
/
app.js
File metadata and controls
31 lines (28 loc) · 806 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
const express = require("express");
const fs = require("fs");
const app = express();
const http = require("http").createServer(app);
const io = require("socket.io")(http);
io.on("connection", (socket) => {
io.emit("restart");
socket.on("audioblob", ({ audioBlob, index }) => {
socket.broadcast.emit("audioblob", {
socketId: socket.id,
audioBlob,
index,
});
// For writing to file to save audio
/*
fs.appendFile("./public/dist/song.wav", audioBlob, (err) => {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
*/
});
console.log(`${socket.id} connected`);
});
app.use(express.static("public"));
const port = process.env.PORT || 3061;
http.listen(port, () => {
console.log(`listening on *:${port}`);
});