增加对当前连接发送消息的方法
This commit is contained in:
24
message/message.go
Normal file
24
message/message.go
Normal file
@ -0,0 +1,24 @@
|
||||
// Package message ...
|
||||
//
|
||||
// Description : 消息相关操作
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 2021-03-28 5:15 下午
|
||||
package message
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/go-developer/websocket/context"
|
||||
)
|
||||
|
||||
// Response 对当前连接的相关行为做出响应
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
//
|
||||
// Date : 5:17 下午 2021/3/28
|
||||
func Response(wsCtx *context.WSContext, data map[string]interface{}) error {
|
||||
byteData, _ := json.Marshal(data)
|
||||
return wsCtx.Session.Write(byteData)
|
||||
}
|
Reference in New Issue
Block a user