Reworked message format, added support for audio messages, made Message class #10
18
app.js
18
app.js
@ -290,11 +290,11 @@ function setupTalkButton() {
|
|||||||
const audioMessage = {
|
const audioMessage = {
|
||||||
type: 'audio',
|
type: 'audio',
|
||||||
name: config.userName,
|
name: config.userName,
|
||||||
audio: b4a.toString(buffer, 'base64'),
|
|
||||||
audioType: audioBlob.type,
|
|
||||||
avatar: updatePortInUrl(config.userAvatar),
|
avatar: updatePortInUrl(config.userAvatar),
|
||||||
topic: topic,
|
topic: topic,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now(),
|
||||||
|
audio: b4a.toString(buffer, 'base64'),
|
||||||
|
audioType: audioBlob.type
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('Sending audio message:', audioMessage); // Debugging log
|
console.log('Sending audio message:', audioMessage); // Debugging log
|
||||||
@ -565,10 +565,10 @@ async function sendMessage(e) {
|
|||||||
const messageObj = JSON.stringify({
|
const messageObj = JSON.stringify({
|
||||||
type: 'message',
|
type: 'message',
|
||||||
name: config.userName,
|
name: config.userName,
|
||||||
message,
|
|
||||||
avatar: config.userAvatar,
|
avatar: config.userAvatar,
|
||||||
topic: topic,
|
topic: topic,
|
||||||
timestamp: timestamp
|
timestamp: timestamp,
|
||||||
|
message
|
||||||
});
|
});
|
||||||
|
|
||||||
const peers = [...activeRooms.find(room => room.topic === topic).swarm.connections];
|
const peers = [...activeRooms.find(room => room.topic === topic).swarm.connections];
|
||||||
@ -592,12 +592,12 @@ async function handleFileInput(event) {
|
|||||||
const fileMessage = {
|
const fileMessage = {
|
||||||
type: 'file',
|
type: 'file',
|
||||||
name: config.userName,
|
name: config.userName,
|
||||||
fileName: file.name,
|
|
||||||
file: b4a.toString(buffer, 'base64'),
|
|
||||||
fileType: file.type,
|
|
||||||
avatar: updatePortInUrl(config.userAvatar),
|
avatar: updatePortInUrl(config.userAvatar),
|
||||||
topic: topic,
|
topic: topic,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now(),
|
||||||
|
fileName: file.name,
|
||||||
|
file: b4a.toString(buffer, 'base64'),
|
||||||
|
fileType: file.type
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('Sending file message:', fileMessage); // Debugging log
|
console.log('Sending file message:', fileMessage); // Debugging log
|
||||||
|
Loading…
Reference in New Issue
Block a user