Merge branch 'branch-v2' into branch-1
This commit is contained in:
@@ -100,7 +100,7 @@ export const GetAllProjects = async (data: GetProjectsInterface) => {
|
|||||||
.find({
|
.find({
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("_id projectName createdBy thumbnail createdAt");
|
.select("_id projectName createdBy thumbnail createdAt projectUuid");
|
||||||
if (projectDatas) return { status: "Success", Datas: projectDatas };
|
if (projectDatas) return { status: "Success", Datas: projectDatas };
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
return { status: error };
|
return { status: error };
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { addfloat, deletefloat, duplicatefloat } from '../services/visualization
|
|||||||
import { addTemplate, addTemplateZone, TemplateZoneDelete } from '../services/visualization/templateServices.ts';
|
import { addTemplate, addTemplateZone, TemplateZoneDelete } from '../services/visualization/templateServices.ts';
|
||||||
import { deleteAssetModel, replaceEventDatas, setAssetModel } from '../services/assets/asset-Controller.ts';
|
import { deleteAssetModel, replaceEventDatas, setAssetModel } from '../services/assets/asset-Controller.ts';
|
||||||
import { add3Dwidget, delete3Dwidget, update3D } from '../services/visualization/3dWidget-Service.ts';
|
import { add3Dwidget, delete3Dwidget, update3D } from '../services/visualization/3dWidget-Service.ts';
|
||||||
|
import { projectDeleteHandleEvent, projectHandleEvent, projecUpdateHandleEvent } from '../controllers/project/projectController.ts';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ const floorItemsHandleEvent = async (event: string, socket: Socket, data: any, i
|
|||||||
// console.error(`Unhandled event type: ${event}`);
|
// console.error(`Unhandled event type: ${event}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const wallItemsHandleEvent =async (event: string, socket: Socket, data: any,io:any) => {
|
const wallItemsHandleEvent = async (event: string, socket: Socket, data: any, io: any) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
return;
|
return;
|
||||||
@@ -266,7 +267,7 @@ const wallItemsHandleEvent =async (event: string, socket: Socket, data: any,io:a
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
const lineHandleEvent =async (event: string, socket: Socket, data: any,io:any) => {
|
const lineHandleEvent = async (event: string, socket: Socket, data: any, io: any) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
return;
|
return;
|
||||||
@@ -378,7 +379,7 @@ const lineHandleEvent =async (event: string, socket: Socket, data: any,io:any) =
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
const userStatus =async (event: string, socket: Socket, data: any,io:any) => {
|
const userStatus = async (event: string, socket: Socket, data: any, io: any) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
return;
|
return;
|
||||||
@@ -476,7 +477,7 @@ const zoneHandleEvent = async (event: string, socket: Socket, data: any, io: any
|
|||||||
const responseEvent = EVENTS.ZoneDeleteResponse
|
const responseEvent = EVENTS.ZoneDeleteResponse
|
||||||
// console.log('responseEvent: ', responseEvent);
|
// console.log('responseEvent: ', responseEvent);
|
||||||
const organization = result?.organization
|
const organization = result?.organization
|
||||||
if (organization) {
|
if (organization) {
|
||||||
socket.to(organization).emit(responseEvent, {
|
socket.to(organization).emit(responseEvent, {
|
||||||
success: result.success,
|
success: result.success,
|
||||||
message: result.message,
|
message: result.message,
|
||||||
@@ -598,7 +599,7 @@ const panelHandleEvent = async (event: string, socket: Socket, data: any, namesp
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
const widgetHandleEvent = async (event: string, socket: Socket, data: any, namespace: any, notifySender: boolean = false,callback:any) => {
|
const widgetHandleEvent = async (event: string, socket: Socket, data: any, namespace: any, notifySender: boolean = false, callback: any) => {
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
return;
|
return;
|
||||||
@@ -607,7 +608,7 @@ const widgetHandleEvent = async (event: string, socket: Socket, data: any, names
|
|||||||
let result;
|
let result;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVENTS.addWidget: {
|
case EVENTS.addWidget: {
|
||||||
result = await addWidget(data,callback);
|
result = await addWidget(data, callback);
|
||||||
// console.log('result: ', result);
|
// console.log('result: ', result);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -615,7 +616,7 @@ const widgetHandleEvent = async (event: string, socket: Socket, data: any, names
|
|||||||
const responseEvent = EVENTS.widgetUpdateResponse
|
const responseEvent = EVENTS.widgetUpdateResponse
|
||||||
// console.log('responseEvent: ', responseEvent);
|
// console.log('responseEvent: ', responseEvent);
|
||||||
const organization = result?.organization
|
const organization = result?.organization
|
||||||
if (organization) {
|
if (organization) {
|
||||||
socket.to(organization).emit(responseEvent, {
|
socket.to(organization).emit(responseEvent, {
|
||||||
success: result.success,
|
success: result.success,
|
||||||
message: result.message,
|
message: result.message,
|
||||||
@@ -659,7 +660,7 @@ const widgetHandleEvent = async (event: string, socket: Socket, data: any, names
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
const floatHandleEvent = async (event: string, socket: Socket, data: any, namespace: any, notifySender: boolean = false,callback:any) => {
|
const floatHandleEvent = async (event: string, socket: Socket, data: any, namespace: any, notifySender: boolean = false, callback: any) => {
|
||||||
// console.log('data: ', data);
|
// console.log('data: ', data);
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
@@ -715,7 +716,7 @@ const floatHandleEvent = async (event: string, socket: Socket, data: any, namesp
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case EVENTS.duplicatefloat: {
|
case EVENTS.duplicatefloat: {
|
||||||
const result = await duplicatefloat(data,callback)
|
const result = await duplicatefloat(data, callback)
|
||||||
if (result) {
|
if (result) {
|
||||||
// console.log('result?.success: ', result.organization);
|
// console.log('result?.success: ', result.organization);
|
||||||
const responseEvent = EVENTS.duplicatefloatUpdateResponse
|
const responseEvent = EVENTS.duplicatefloatUpdateResponse
|
||||||
@@ -824,7 +825,7 @@ const templateHandleEvent = async (event: string, socket: Socket, data: any, nam
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
const Widget3DHandleEvent = async (event: string, socket: Socket, data: any, namespace: any, notifySender: boolean = false,callback:any ) => {
|
const Widget3DHandleEvent = async (event: string, socket: Socket, data: any, namespace: any, notifySender: boolean = false, callback: any) => {
|
||||||
// console.log('data: ', data);
|
// console.log('data: ', data);
|
||||||
if (!data?.organization) {
|
if (!data?.organization) {
|
||||||
console.warn(`Missing organization for event: ${event}`);
|
console.warn(`Missing organization for event: ${event}`);
|
||||||
@@ -834,7 +835,7 @@ const Widget3DHandleEvent = async (event: string, socket: Socket, data: any, nam
|
|||||||
let result;
|
let result;
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVENTS.add3DWidget: {
|
case EVENTS.add3DWidget: {
|
||||||
result = await add3Dwidget(data,callback);
|
result = await add3Dwidget(data, callback);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
const responseEvent = EVENTS.widget3DUpdateResponse
|
const responseEvent = EVENTS.widget3DUpdateResponse
|
||||||
@@ -903,7 +904,7 @@ const Widget3DHandleEvent = async (event: string, socket: Socket, data: any, nam
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// case EVENTS.deleteWidget: {
|
// case EVENTS.deleteWidget: {
|
||||||
// const result = await Widgetdelete(data)
|
// const result = await Widgetdelete(data)
|
||||||
// if (result) {
|
// if (result) {
|
||||||
// // console.log('result?.success: ', result.organization);
|
// // console.log('result?.success: ', result.organization);
|
||||||
@@ -948,14 +949,14 @@ const modelAssetHandleEvent = async (event: string, socket: Socket, data: any, n
|
|||||||
result = await setAssetModel(data);
|
result = await setAssetModel(data);
|
||||||
if (result) emitEventResponse(socket, result.organization, EVENTS.assetUpdateResponse, result);
|
if (result) emitEventResponse(socket, result.organization, EVENTS.assetUpdateResponse, result);
|
||||||
break;
|
break;
|
||||||
case EVENTS.deleteAssetModel:
|
case EVENTS.deleteAssetModel:
|
||||||
result = await deleteAssetModel(data);
|
result = await deleteAssetModel(data);
|
||||||
if (result) emitEventResponse(socket, result.organization, EVENTS.assetDeleteResponse, result);
|
if (result) emitEventResponse(socket, result.organization, EVENTS.assetDeleteResponse, result);
|
||||||
break;
|
break;
|
||||||
case EVENTS.assetEventData:
|
case EVENTS.assetEventData:
|
||||||
result = await replaceEventDatas(data);
|
result = await replaceEventDatas(data);
|
||||||
if (result) emitEventResponse(socket, result.organization, EVENTS.assetEventDataResponse, result);
|
if (result) emitEventResponse(socket, result.organization, EVENTS.assetEventDataResponse, result);
|
||||||
break;
|
break;
|
||||||
// case EVENTS.setAssetModel: {
|
// case EVENTS.setAssetModel: {
|
||||||
// result = await setAssetModel(data);
|
// result = await setAssetModel(data);
|
||||||
|
|
||||||
@@ -1035,22 +1036,22 @@ const simulationHandleEvent = async (event: string, socket: Socket, data: any,)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let result;
|
let result;
|
||||||
try {
|
try {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case EVENTS.setAssetModel:
|
case EVENTS.setAssetModel:
|
||||||
result = await addTemplate(data);
|
result = await addTemplate(data);
|
||||||
if (result) emitEventResponse(socket, result.organization, EVENTS.zoneUpdateResponse, result);
|
if (result) emitEventResponse(socket, result.organization, EVENTS.zoneUpdateResponse, result);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.warn(`❌ Unknown event received: ${event}`);
|
console.warn(`❌ Unknown event received: ${event}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`❌ Error handling event ${event}:`, error);
|
console.error(`❌ Error handling event ${event}:`, error);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
const emitEventResponse = (socket: Socket, organization: string, event: string, result: any) => {
|
||||||
}
|
|
||||||
const emitEventResponse = (socket: Socket, organization: string, event: string, result: any) => {
|
|
||||||
if (organization) {
|
if (organization) {
|
||||||
socket.to(organization).emit(event, {
|
socket.to(organization).emit(event, {
|
||||||
success: result.success,
|
success: result.success,
|
||||||
@@ -1109,6 +1110,8 @@ export const initSocketServer = (httpServer: any) => {
|
|||||||
// zone: io.of("/zone"),
|
// zone: io.of("/zone"),
|
||||||
Builder: io.of('/Builder'),
|
Builder: io.of('/Builder'),
|
||||||
visualization: io.of('/Visualization'),
|
visualization: io.of('/Visualization'),
|
||||||
|
project: io.of('/project'),
|
||||||
|
|
||||||
// widget:io.of('/widget')
|
// widget:io.of('/widget')
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1124,7 +1127,7 @@ export const initSocketServer = (httpServer: any) => {
|
|||||||
|
|
||||||
// const organization = socket.handshake.query.organization as string;
|
// const organization = socket.handshake.query.organization as string;
|
||||||
// const email = socket.handshake.query.email as string;
|
// const email = socket.handshake.query.email as string;
|
||||||
const {organization,email} = socket.handshake.auth
|
const { organization, email } = socket.handshake.auth
|
||||||
// console.log(`🔍 Received organization: ${organization}`);
|
// console.log(`🔍 Received organization: ${organization}`);
|
||||||
|
|
||||||
if (organization) {
|
if (organization) {
|
||||||
@@ -1134,18 +1137,18 @@ export const initSocketServer = (httpServer: any) => {
|
|||||||
// Handle all events
|
// Handle all events
|
||||||
if (organization && email) {
|
if (organization && email) {
|
||||||
if (!onlineUsers[organization]) {
|
if (!onlineUsers[organization]) {
|
||||||
onlineUsers[organization] = new Set();
|
onlineUsers[organization] = new Set();
|
||||||
}
|
}
|
||||||
onlineUsers[organization].add(socket.id);
|
onlineUsers[organization].add(socket.id);
|
||||||
// console.log('onlineUsers: ', onlineUsers);
|
// console.log('onlineUsers: ', onlineUsers);
|
||||||
|
|
||||||
// console.log(`✅ User ${email} joined ${organization}. Active users:`, onlineUsers[organization]);
|
// console.log(`✅ User ${email} joined ${organization}. Active users:`, onlineUsers[organization]);
|
||||||
}
|
}
|
||||||
|
|
||||||
userStatus(EVENTS.connection, socket, socket.handshake.auth, socket);
|
userStatus(EVENTS.connection, socket, socket.handshake.auth, socket);
|
||||||
|
|
||||||
socket.onAny((event: string, data: any ,callback:any) => {
|
socket.onAny((event: string, data: any, callback: any) => {
|
||||||
eventHandlers.forEach(handler => handler(event, socket, data, namespace,io,callback));
|
eventHandlers.forEach(handler => handler(event, socket, data, namespace, io, callback));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle disconnection
|
// Handle disconnection
|
||||||
@@ -1178,8 +1181,8 @@ export const initSocketServer = (httpServer: any) => {
|
|||||||
// handleNamespace("zone", namespaces.zone, zoneHandleEvent);
|
// handleNamespace("zone", namespaces.zone, zoneHandleEvent);
|
||||||
// handleNamespace("visualization", namespaces.panel, panelHandleEvent);
|
// handleNamespace("visualization", namespaces.panel, panelHandleEvent);
|
||||||
// handleNamespace("widget", namespaces.visualization, widgetHandleEvent);
|
// handleNamespace("widget", namespaces.visualization, widgetHandleEvent);
|
||||||
handleNamespace("Builder", namespaces.Builder, userStatus,modelAssetHandleEvent, cameraHandleEvent, EnvironmentHandleEvent, wallItemsHandleEvent, lineHandleEvent,zoneHandleEvent);
|
handleNamespace("Builder", namespaces.Builder, userStatus, modelAssetHandleEvent, cameraHandleEvent, EnvironmentHandleEvent, wallItemsHandleEvent, lineHandleEvent, zoneHandleEvent);
|
||||||
handleNamespace("Visualization", namespaces.visualization, panelHandleEvent, widgetHandleEvent, floatHandleEvent, templateHandleEvent,Widget3DHandleEvent);
|
handleNamespace("Visualization", namespaces.visualization, panelHandleEvent, widgetHandleEvent, floatHandleEvent, templateHandleEvent, Widget3DHandleEvent);
|
||||||
|
handleNamespace("project", namespaces.project, projectHandleEvent, projectDeleteHandleEvent, projecUpdateHandleEvent)
|
||||||
return io;
|
return io;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user