faet: 新增WS模块
This commit is contained in:
30
src/modules/ws/service/ws_receive.impl.go
Normal file
30
src/modules/ws/service/ws_receive.impl.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user