Work in progress - blocage working on it ./app 206
This commit is contained in:
parent
8500d7dbe2
commit
f506fb44bf
11 changed files with 201 additions and 33 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { addMessage } from "./addMessage";
|
||||
import { Socket } from 'socket.io-client';
|
||||
import { getUser } from "@app/auth";
|
||||
|
||||
import type { ClientMessage } from "./types_front";
|
||||
/**
|
||||
* function sends socket.emit to the backend to active and broadcast a message to all sockets
|
||||
* echos the message with addMessage to the sender
|
||||
|
|
@ -13,15 +13,21 @@ export function broadcastMsg (socket: Socket, msgCommand: string[]): void {
|
|||
addMessage(msgText);
|
||||
const user = getUser();
|
||||
if (user && socket?.connected) {
|
||||
const message = {
|
||||
command: msgCommand,
|
||||
const message: ClientMessage = {
|
||||
command: msgCommand[0],
|
||||
destination: '',
|
||||
type: "chat",
|
||||
user: user.name,
|
||||
token: document.cookie,
|
||||
text: msgText,
|
||||
timestamp: Date.now(),
|
||||
SenderWindowID: socket.id,
|
||||
SenderWindowID: socket.id ?? "",
|
||||
SenderUserName: user.name,
|
||||
SenderUserID: user.id,
|
||||
userID: '',
|
||||
frontendUserName: '',
|
||||
frontendUser: '',
|
||||
Sendertext: '',
|
||||
};
|
||||
socket.emit('message', JSON.stringify(message));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue