perf: ws模块telnet分开处理避免类型指针错误导致panic程序崩溃
This commit is contained in:
@@ -181,7 +181,7 @@ func (s *WSImpl) ClientReadListen(wsClient *model.WSClient, receiveType int) {
|
||||
if messageType == websocket.TextMessage {
|
||||
var reqMsg model.WSRequest
|
||||
if err := json.Unmarshal(msg, &reqMsg); err != nil {
|
||||
msgByte, _ := json.Marshal(result.ErrMsg("message format not supported"))
|
||||
msgByte, _ := json.Marshal(result.ErrMsg("message format json error"))
|
||||
wsClient.MsgChan <- msgByte
|
||||
continue
|
||||
}
|
||||
@@ -193,6 +193,8 @@ func (s *WSImpl) ClientReadListen(wsClient *model.WSClient, receiveType int) {
|
||||
go NewWSReceiveImpl.Shell(wsClient, reqMsg)
|
||||
case ReceiveShellView:
|
||||
go NewWSReceiveImpl.ShellView(wsClient, reqMsg)
|
||||
case ReceiveTelnet:
|
||||
go NewWSReceiveImpl.Telnet(wsClient, reqMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ const (
|
||||
ReceiveCommont = iota // Commont 接收通用业务处理
|
||||
ReceiveShell // Shell 接收终端交互业务处理
|
||||
ReceiveShellView // ShellView 接收查看文件终端交互业务处理
|
||||
ReceiveTelnet // Telnet 接收终端交互业务处理
|
||||
)
|
||||
|
||||
// IWSReceive WebSocket消息接收处理 服务层接口
|
||||
@@ -18,4 +19,7 @@ type IWSReceive interface {
|
||||
|
||||
// ShellView 接收查看文件终端交互业务处理
|
||||
ShellView(client *model.WSClient, reqMsg model.WSRequest)
|
||||
|
||||
// Telnet 接收终端交互业务处理
|
||||
Telnet(client *model.WSClient, reqMsg model.WSRequest)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user