server-socket-framework-jps
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -29,3 +29,3 @@ /// <reference types="node" /> | ||
protected sendQueuedItemsToUser(user: ChatUser, queuedItems: QueuedMessages): void; | ||
protected createMessageForRoom(author: string, roomName: string, message: string, created: number, type: number, priority: number | undefined, simpleAttachment: any, attachment?: any): ChatMessage | null; | ||
protected createMessageForRoom(author: string, id: string, roomName: string, message: string, created: number, type: number, priority: number | undefined, simpleAttachment: any, attachment?: any): ChatMessage | null; | ||
protected addUserToRoom(socketId: string, username: string, roomName: string, type: number): void; | ||
@@ -32,0 +32,0 @@ protected removeUserFromRoom(username: string, roomName: string, type: number): void; |
@@ -143,6 +143,6 @@ "use strict"; | ||
}); | ||
socket.on('chat', ({ from, room, message, created, priority, simpleAttachment, attachment, type }) => { | ||
socket.on('chat', ({ from, id, room, message, created, priority, simpleAttachment, attachment, type }) => { | ||
socketDebug(`${from} has sent a message to room ${room}: ${message}`); | ||
// send the message to the rest of the room | ||
let cMessage = this.createMessageForRoom(from, room, message, created, type, priority, simpleAttachment, attachment); | ||
let cMessage = this.createMessageForRoom(from, id, room, message, created, type, priority, simpleAttachment, attachment); | ||
if (cMessage) { | ||
@@ -158,2 +158,8 @@ socketDebug(`Sending message ${cMessage.message} to room ${cMessage.room}`); | ||
}); | ||
socket.on('chatReceived', ({ id, room, receivedBy }) => { | ||
socketDebug(`${receivedBy} has received message ${id} to room ${room}`); | ||
// send the message to the rest of the room | ||
socketDebug(`Sending message received ${id} to room ${room}`); | ||
socket.to(room).emit('chatReceived', JSON.stringify({ id, room, receivedBy })); | ||
}); | ||
socket.on('userlist', () => { | ||
@@ -265,3 +271,3 @@ // return the list of who is logged in | ||
} | ||
createMessageForRoom(author, roomName, message, created, type, priority = 0, simpleAttachment, attachment = {}) { | ||
createMessageForRoom(author, id, roomName, message, created, type, priority = 0, simpleAttachment, attachment = {}) { | ||
let sender = this.findUser(author); | ||
@@ -271,2 +277,3 @@ let chatMessage = null; | ||
chatMessage = { | ||
id: id, | ||
from: author, | ||
@@ -273,0 +280,0 @@ room: roomName, |
@@ -26,2 +26,3 @@ export declare enum DataMessageType { | ||
export declare type ChatMessage = { | ||
id: string; | ||
room: string; | ||
@@ -36,2 +37,7 @@ message: string; | ||
}; | ||
export declare type ChatMessageReceived = { | ||
id: string; | ||
room: string; | ||
receivedBy: string; | ||
}; | ||
export declare type InviteMessage = { | ||
@@ -38,0 +44,0 @@ from: string; |
{ | ||
"name": "server-socket-framework-jps", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "A simple socket framework for persistent chat rooms and data messages", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
82536
1154