Up to date fork #1

Merged
MiTask merged 33 commits from snxraven/LinkUp-P2P-Chat:main into main 2024-06-14 04:32:25 -04:00
3 changed files with 12 additions and 8 deletions
Showing only changes of commit b9db313eff - Show all commits

View File

@ -48,6 +48,10 @@ class Client extends EventEmitter {
}
joinChatRoom(chatRoomID) {
if (!chatRoomID || typeof chatRoomID !== 'string') {
return console.error("Invalid chat room ID!");
}
this.joinedRooms.add(chatRoomID); // Add the room to the list of joined rooms
this.currentTopic = chatRoomID; // Store the current topic
this.discovery = this.swarm.join(Buffer.from(chatRoomID, 'hex'), { client: true, server: true });

View File

@ -1,5 +1,5 @@
class FileMessage {
public FileMessage(peerName, fileName, fileUrl, fileType, peerAvatar, topic, timestamp) {
constructor(peerName, fileName, fileUrl, fileType, peerAvatar, topic, timestamp) {
this.peerName = peerName;
this.fileName = fileName;
this.fileUrl = fileUrl;
@ -9,7 +9,7 @@ class FileMessage {
this.timestamp = timestamp;
}
public toJsonString() {
toJsonString() {
return JSON.stringify({
type: 'file',
name: this.peerName,

View File

@ -1,5 +1,5 @@
class TextMessage {
public TextMessage(peerName, peerAvatar, topic, message, timestamp) {
constructor(peerName, peerAvatar, topic, message, timestamp) {
this.peerName = peerName;
this.peerAvatar = peerAvatar;
this.topic = topic;
@ -7,7 +7,7 @@ class TextMessage {
this.timestamp = timestamp;
}
public toJsonString() {
toJsonString() {
return JSON.stringify({
type: 'message',
name: this.peerName,
@ -18,7 +18,7 @@ class TextMessage {
});
}
public static new(bot, message) {
static new(bot, message) {
return new TextMessage(bot.botName, "", bot.currentTopic, message, Date.now());
}
}