1 Star 0 Fork 0

ggymm/desktop-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
im_handler.go 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
ggymm 提交于 2021-05-12 23:12 . 完善socket
package main
import (
"time"
"desktop-go/message"
"google.golang.org/protobuf/proto"
)
func (c *ChatClient) heartbeat(msg *message.Message) {
tickMsg := &message.Message{
From: 1,
To: msg.From,
Cmd: message.CommandType_HEARTBEAT,
}
tickMsgData, _ := proto.Marshal(tickMsg)
pbData, _ := Encode(tickMsgData)
_, _ = c.imConn.Write(pbData)
}
func (c *ChatClient) imLoginReq(wsMsg WsRequest) {
msg := &message.Message{
To: ServerId,
Cmd: message.CommandType_LOGIN_REQ,
CreateTime: time.Now().UnixNano() / 1e6,
Content: wsMsg.Token,
}
data, _ := proto.Marshal(msg)
pbData, err := Encode(data)
if err != nil {
Logger.Errorf("[IM客户端]登录消息编码错误, %v", err)
return
}
_, _ = c.imConn.Write(pbData)
}
func (c *ChatClient) imLoginResp(msg *message.Message) {
if msg.Content == "success" {
Logger.Debug("[IM客户端]登录成功")
} else {
Logger.Debugf("[IM客户端]登录失败, %s", msg.Content)
}
c.wsLoginResp(msg.Content == "success")
c.userId = msg.To
}
func (c *ChatClient) imMsgAck(msg *message.Message) {
}
func (c *ChatClient) imMsgNotify(msg *message.Message) {
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/1967988842/desktop-go.git
git@gitee.com:1967988842/desktop-go.git
1967988842
desktop-go
desktop-go
master

搜索帮助