import Message from "./Message.js"; import b4a from "b4a"; class AudioMessage extends Message { constructor(peerName, peerAvatar, topic, timestamp, audioUrl, audioType, audioData) { super("audio", peerName, peerAvatar, topic, timestamp); this.audioUrl = audioUrl; this.audioType = audioType; this.audioData = audioData; // Add audio data property } toJsonString() { return JSON.stringify({ ...this.toJson(), audioUrl: this.audioUrl, audioType: this.audioType, audio: this.audioData // Include audio data in JSON }); } static new(bot, audioUrl, audioType, audioBuffer) { const audioData = b4a.toString(audioBuffer, 'base64'); // Convert audio buffer to base64 return new AudioMessage(bot.botName, bot.botAvatar, bot.currentTopic, Date.now(), audioUrl, audioType, audioData); } } export default AudioMessage;