From 4aa205cd731b9dddfa21cb98cfb1d765097930c5 Mon Sep 17 00:00:00 2001 From: MrMasrozYTLIVE <61359286+MrMasrozYTLIVE@users.noreply.github.com> Date: Tue, 11 Jun 2024 20:56:02 +0300 Subject: [PATCH] Got rid of 2 useless classes --- chatBot/includes/ChatRoom.js | 8 -------- chatBot/includes/Client.js | 18 ++---------------- chatBot/includes/UserPeer.js | 10 ---------- 3 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 chatBot/includes/ChatRoom.js delete mode 100644 chatBot/includes/UserPeer.js diff --git a/chatBot/includes/ChatRoom.js b/chatBot/includes/ChatRoom.js deleted file mode 100644 index 0686013..0000000 --- a/chatBot/includes/ChatRoom.js +++ /dev/null @@ -1,8 +0,0 @@ -class ChatRoom { - public ChatRoom(topic, peers) { - this.topic = topic; - this.peers = peers; - } -} - -export default ChatRoom; \ No newline at end of file diff --git a/chatBot/includes/Client.js b/chatBot/includes/Client.js index f249b23..5c82352 100644 --- a/chatBot/includes/Client.js +++ b/chatBot/includes/Client.js @@ -46,22 +46,8 @@ class Client extends EventEmitter { }); } - sendMessage(roomPeers, message) { - console.log('Bot name:', this.botName); - const timestamp = Date.now(); - const messageObj = { - type: 'message', - name: this.botName, - message, - timestamp, - topic: this.currentTopic // Include the current topic - }; - const data = JSON.stringify(messageObj); - const peers = [...this.swarm.connections].filter(peer => roomPeers.includes(peer.remotePublicKey.toString('hex'))); - for (const peer of peers) peer.write(data); - } - - sendMessageToAll(message) { + // TODO: Make topic here actually work. + sendMessage(topic, message) { console.log('Bot name:', this.botName); const timestamp = Date.now(); const messageObj = { diff --git a/chatBot/includes/UserPeer.js b/chatBot/includes/UserPeer.js deleted file mode 100644 index 9546499..0000000 --- a/chatBot/includes/UserPeer.js +++ /dev/null @@ -1,10 +0,0 @@ -class UserPeer { - public UserPeer(peer, topics, username, avatar) { - this.peer = peer; - this.topics = topics; - this.username = username; - this.avatar = avatar; - } -} - -export default UserPeer; \ No newline at end of file