From 4529e4287679de8c7aeaf4acd332df1c650415c9 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 31 Aug 2023 14:38:34 +0800 Subject: [PATCH] fix --- constants/websocket.go | 5 +++++ ...ctory.go => ws_allocation_processing_factory.go} | 0 server/websocket/internal/logic/ws_render_image.go | 13 ++++++++----- .../internal/logic/ws_system_data_update_notify.go | 8 ++++++++ 4 files changed, 21 insertions(+), 5 deletions(-) rename server/websocket/internal/logic/{allocation_processing_factory.go => ws_allocation_processing_factory.go} (100%) create mode 100644 server/websocket/internal/logic/ws_system_data_update_notify.go diff --git a/constants/websocket.go b/constants/websocket.go index dd648800..da7d8618 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -30,3 +30,8 @@ const ( WEBSOCKET_ASSEMBLE_RENDER_DATA Websocket = "WEBSOCKET_ASSEMBLE_RENDER_DATA" //组装unity需要的数据 (2级消息,单向通信,属于 WEBSOCKET_RENDER_IMAGE 消息的子流程) WEBSOCKET_SEND_DATA_TO_UNITY Websocket = "WEBSOCKET_SEND_DATA_TO_UNITY" //发送到unity进行渲染 (2级消息,单向通信,属于 WEBSOCKET_RENDER_IMAGE 消息的子流程) ) + +// websocket消息类型(系统数据变更通知) +const ( + WEBSOCKET_SYSTEM_DATA_UPDATE_NOTIFY Websocket = "WEBSOCKET_SYSTEM_DATA_UPDATE_NOTIFY" //系统数据更新(1级消息,单向通信) +) diff --git a/server/websocket/internal/logic/allocation_processing_factory.go b/server/websocket/internal/logic/ws_allocation_processing_factory.go similarity index 100% rename from server/websocket/internal/logic/allocation_processing_factory.go rename to server/websocket/internal/logic/ws_allocation_processing_factory.go diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 39ab91bc..c3aeb0ad 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -218,7 +218,7 @@ func (w *wsConnectItem) renderImage(data []byte) { } } else { //返回给客户端 - b := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ + w.sendRenderResultData(websocket_data.RenderImageRspMsg{ RenderId: renderImageData.RenderId, Image: *resource.ResourceUrl, RenderProcessTime: websocket_data.RenderProcessTime{ @@ -228,8 +228,6 @@ func (w *wsConnectItem) renderImage(data []byte) { UploadUnityRenderImageTakesTime: "cache", }, }) - //发送数据到out chan - w.sendToOutChan(b) return } //########################################### @@ -387,6 +385,11 @@ func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId})) } +// 发送渲染最终结果数据到前端 +func (w *wsConnectItem) sendRenderResultData(data websocket_data.RenderImageRspMsg) { + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, data)) +} + // 增加渲染任务 func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) { if data.taskId == "" { @@ -511,7 +514,7 @@ func (w *wsConnectItem) operationRenderTask() { uploadUnityRenderImageTakesTime = fmt.Sprintf("%dms", taskData.uploadUnityRenderImageTakesTime) } //发送到出口 - w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ + w.sendRenderResultData(websocket_data.RenderImageRspMsg{ RenderId: taskData.renderId, Image: data.renderNotifyImageUrl, RenderProcessTime: websocket_data.RenderProcessTime{ @@ -520,7 +523,7 @@ func (w *wsConnectItem) operationRenderTask() { UploadCombineImageTakesTime: uploadCombineImageTakesTime, UploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime, }, - })) + }) //删除任务 delete(w.extendRenderProperty.renderImageTask, data.taskId) case 1: //新增任务 diff --git a/server/websocket/internal/logic/ws_system_data_update_notify.go b/server/websocket/internal/logic/ws_system_data_update_notify.go new file mode 100644 index 00000000..93e90a8c --- /dev/null +++ b/server/websocket/internal/logic/ws_system_data_update_notify.go @@ -0,0 +1,8 @@ +package logic + +import "fusenapi/constants" + +// 发送系统更新数据给前端 +func (w *wsConnectItem) sendSystemDataUpdateNotifyMessage(data interface{}) { + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SYSTEM_DATA_UPDATE_NOTIFY, data)) +}