forked from snxraven/LinkUp-P2P-Chat
Up to date fork #1
@ -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 });
|
||||
|
@ -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,
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user