faet: 新增WS模块

This commit is contained in:
TsMask
2024-01-23 18:06:44 +08:00
parent 413f0b4951
commit 89499c9d28
12 changed files with 673 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package service
import (
"fmt"
"ems.agt/src/modules/ws/model"
"ems.agt/src/modules/ws/processor"
)
// 实例化服务层 WSReceiveImpl 结构体
var NewWSReceiveImpl = &WSReceiveImpl{}
// WSReceiveImpl WebSocket消息接收处理 服务层处理
type WSReceiveImpl struct{}
// Receive 接收处理
func (s *WSReceiveImpl) Receive(client *model.WSClient, reqMsg model.WSRequest) error {
fmt.Println(client.ID, reqMsg)
switch reqMsg.Type {
case "ps":
res, err := processor.GetProcessData(reqMsg.Data)
if err != nil {
return err
}
client.MsgChan <- res
default:
return fmt.Errorf("message type not supported")
}
return nil
}