fusenapi/server/websocket/internal/logic/ws_allocation_processing_factory.go
laodaming 4529e42876 fix
2023-08-31 14:38:34 +08:00

34 lines
787 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{}
//刷新重连请求恢复上次连接的标识
case constants.WEBSOCKET_REQUEST_REUSE_LAST_CONNECT:
obj = &reuseConnProcessor{}
default:
}
if obj != nil {
mapAllocationProcessor[msgType] = obj
}
return obj
}