Cleaned un the type obj - now consistant through out
This commit is contained in:
parent
f5366bf9e1
commit
e543116b5d
2 changed files with 32 additions and 8 deletions
|
|
@ -31,6 +31,21 @@ export type blockedUnBlocked =
|
|||
by: string,
|
||||
};
|
||||
|
||||
export type obj =
|
||||
{
|
||||
command: string,
|
||||
destination: string,
|
||||
type: string,
|
||||
user: string,
|
||||
frontendUserName: string,
|
||||
frontendUser: string,
|
||||
token: string,
|
||||
text: string,
|
||||
timestamp: number,
|
||||
SenderWindowID: string,
|
||||
Sendertext: string,
|
||||
};
|
||||
|
||||
// get the name of the machine used to connect
|
||||
const machineHostName = window.location.hostname;
|
||||
console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow);
|
||||
|
|
@ -242,7 +257,7 @@ async function openMessagePopup(message: string) {
|
|||
|
||||
const modalmessage = document.getElementById("modal-message") ?? null;
|
||||
if(!message) return
|
||||
const obj:any = JSON.parse(message);
|
||||
const obj:string = JSON.parse(message);
|
||||
if (modalmessage) {
|
||||
const messageElement = document.createElement("div");
|
||||
messageElement.innerHTML = `
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ async function onReady(fastify: FastifyInstance) {
|
|||
socket.on('message', (message: string) => {
|
||||
// console.info(color.blue, 'DEBUG LOG: Socket connected!', color.reset, socket.id);
|
||||
// console.log( color.blue, 'DEBUG LOG: Received message from client', color.reset, message);
|
||||
const obj: ClientMessage = JSON.parse(message) as ClientMessage;
|
||||
const obj: obj = JSON.parse(message) as ClientMessage;
|
||||
clientChat.set(socket.id, { user: obj.user, lastSeen: Date.now() });
|
||||
// console.log(color.green, 'DEBUG LOG: Message from client', color.reset, `Sender: login name: ${obj.user} - windowID ${obj.SenderWindowID} - text message: ${obj.text}`);
|
||||
socket.emit('welcome', { msg: 'Welcome to the chat! : ' });
|
||||
|
|
@ -247,15 +247,18 @@ async function onReady(fastify: FastifyInstance) {
|
|||
|
||||
if (!clientName) return;
|
||||
console.log(color.green, `Client logging out: ${clientName} (${socket.id})`);
|
||||
const obj = {
|
||||
const obj: obj = {
|
||||
command: '',
|
||||
destination: 'system-info',
|
||||
type: 'chat' as const,
|
||||
user: clientName,
|
||||
token: '',
|
||||
text: 'LEFT the chat',
|
||||
frontendUserName: '',
|
||||
frontendUser: '',
|
||||
timestamp: Date.now(),
|
||||
SenderWindowID: socket.id,
|
||||
Sendertext: '',
|
||||
};
|
||||
broadcast(fastify, obj, socket.id);
|
||||
// Optional: remove from map
|
||||
|
|
@ -274,15 +277,18 @@ async function onReady(fastify: FastifyInstance) {
|
|||
if (reason === 'transport error') return;
|
||||
|
||||
if (clientName !== null) {
|
||||
const obj = {
|
||||
const obj: obj = {
|
||||
command: '',
|
||||
destination: 'system-info',
|
||||
type: 'chat',
|
||||
user: clientName,
|
||||
token: '',
|
||||
text: 'LEFT the chat',
|
||||
frontendUserName: '',
|
||||
frontendUser: '',
|
||||
timestamp: Date.now(),
|
||||
SenderWindowID: socket.id,
|
||||
Sendertext: '',
|
||||
};
|
||||
|
||||
broadcast(fastify, obj, obj.SenderWindowID);
|
||||
|
|
@ -299,15 +305,18 @@ async function onReady(fastify: FastifyInstance) {
|
|||
);
|
||||
|
||||
if (clientName !== null) {
|
||||
const obj = {
|
||||
const obj: obj = {
|
||||
command: '',
|
||||
destination: 'system-info',
|
||||
type: 'chat',
|
||||
user: clientName,
|
||||
token: '',
|
||||
text: 'LEFT the chat but the window is still open',
|
||||
frontendUserName: '',
|
||||
frontendUser: '',
|
||||
timestamp: Date.now(),
|
||||
SenderWindowID: socket.id,
|
||||
Sendertext: '',
|
||||
};
|
||||
// console.log(color.blue, 'DEBUG LOG: BROADCASTS OUT :', obj.SenderWindowID);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue