fusenapi/server/websocket/internal/logic/ws_allocation_processing_factory.go
laodaming a138cdbd01 fix
2023-10-11 17:50:08 +08:00

30 lines
676 B
Go

package logic
import (
"fusenapi/constants"
)
// 消息分发工厂
type allocationProcessorFactory interface {
//分配数据到缓冲队列
allocationMessage(w *wsConnectItem, data []byte)
}
var mapAllocationProcessor = make(map[constants.Websocket]allocationProcessorFactory)
func (w *wsConnectItem) newAllocationProcessor(msgType constants.Websocket) allocationProcessorFactory {
if val, ok := mapAllocationProcessor[msgType]; ok {
return val
}
var obj allocationProcessorFactory
switch msgType {
//图片渲染
case constants.WEBSOCKET_RENDER_IMAGE:
obj = &renderProcessor{}
default:
return nil
}
mapAllocationProcessor[msgType] = obj
return obj
}