Fixed in / out chat notification system info
This commit is contained in:
parent
2e422eee2a
commit
7e644fe658
7 changed files with 28 additions and 41 deletions
|
|
@ -174,10 +174,6 @@ async function onReady(fastify: FastifyInstance) {
|
|||
socket.on('privMessage', (data) => {
|
||||
const clientName: string = clientChat.get(socket.id)?.user || '';
|
||||
const prvMessage: ClientMessage = JSON.parse(data) || '';
|
||||
console.log("------------------------------------------------")
|
||||
console.log("PRUV GAME")
|
||||
console.log(data)
|
||||
console.log("------------------------------------------------")
|
||||
if (clientName !== null) {
|
||||
const obj: ClientMessage = {
|
||||
command: prvMessage.command,
|
||||
|
|
@ -187,7 +183,7 @@ async function onReady(fastify: FastifyInstance) {
|
|||
text: prvMessage.text,
|
||||
timestamp: Date.now(),
|
||||
SenderWindowID: socket.id,
|
||||
};``
|
||||
};
|
||||
sendPrivMessage(fastify, obj, obj.SenderWindowID);
|
||||
}
|
||||
});
|
||||
|
|
@ -221,11 +217,6 @@ async function onReady(fastify: FastifyInstance) {
|
|||
socket.on('inviteGame', async (data: string) => {
|
||||
const clientName: string = clientChat.get(socket.id)?.user || '';
|
||||
const profilInvite: ClientProfil = JSON.parse(data) || '';
|
||||
console.log("------------------------------------------------")
|
||||
console.log("INVITE GAME")
|
||||
console.log(data)
|
||||
console.log("------------------------------------------------")
|
||||
|
||||
const linkGame: PongGameId | undefined = await setGameLink(fastify, data);
|
||||
if (!linkGame) return;
|
||||
const link: string = `<a href="https://localhost:8888/app/pong?game=${linkGame}" style="color: blue; text-decoration: underline; cursor: pointer;">Click me</a>`;
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ export async function sendPrivMessage(fastify: FastifyInstance, data: ClientMess
|
|||
|
||||
const sockets = await fastify.io.fetchSockets();
|
||||
const allUsers: User[] = fastify.db.getAllUsers() ?? [];
|
||||
console.log('sender', sender);
|
||||
const senderSocket = sockets.find(socket => socket.id === sender);
|
||||
console.log('senderSOcket', senderSocket?.id);
|
||||
|
||||
for (const socket of sockets) {
|
||||
if (socket.id === sender) continue;
|
||||
|
|
@ -46,20 +44,16 @@ export async function sendPrivMessage(fastify: FastifyInstance, data: ClientMess
|
|||
}
|
||||
|
||||
blockMsgFlag = checkNamePair(list, UserID, receiverUser.id) || false;
|
||||
console.log("userID", UserID);
|
||||
console.log("receiverUserID", receiverUser.id)
|
||||
if (!blockMsgFlag) {
|
||||
socket.emit('MsgObjectServer', { message: data });
|
||||
fastify.log.info({ senderID: `${UserID}`, msgPriv: data.text, target: `${receiverUser.id}` });
|
||||
if (senderSocket) {
|
||||
if (!data.innerHtml) {
|
||||
console.log('privMsg text');
|
||||
senderSocket.emit('privMessageCopy', `${data.command}: ${data.text}🔒`);
|
||||
} else {
|
||||
console.log('privMsg texthtml');
|
||||
}
|
||||
else {
|
||||
senderSocket.emit('privMessageCopy', `${data.command}: ${data.innerHtml}🔒`);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue