This commit is contained in:
laodaming 2023-08-31 14:38:34 +08:00
parent 046ecb0ffb
commit 4529e42876
4 changed files with 21 additions and 5 deletions

View File

@ -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级消息单向通信)
)

View File

@ -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: //新增任务

View File

@ -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))
}