1 Star 0 Fork 0

Bangtsdd/BangLib

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
msg_rtc.go 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
啊哈 提交于 2025-01-09 23:34 . 修改目录
package config
import (
"fmt"
"gitee.com/Bangtsdd/BangLib/common"
"gitee.com/Bangtsdd/BangLib/pkg/util"
)
// rtc 挂断
func (c *Context) SendRTCCallResult(req P2pRtcMessageReq) error {
content := ""
resultType := req.ResultType
switch resultType {
case common.RTCResultTypeCancel:
content = "通话取消"
case common.RTCResultTypeMissed:
content = "未接听"
case common.RTCResultTypeRefuse:
content = "通话拒绝"
case common.RTCResultTypeHangup:
content = fmt.Sprintf("通话时长:%s", formatSecond(req.Second))
}
return c.SendMessage(&MsgSendReq{
Header: MsgHeader{
RedDot: 1,
},
FromUID: req.FromUID,
ChannelID: req.ToUID,
ChannelType: uint8(common.ChannelTypePerson),
Payload: []byte(util.ToJson(map[string]interface{}{
"type": common.VideoCallResult,
"content": content,
"second": req.Second,
"call_type": req.CallType,
"result_type": req.ResultType,
})),
})
}
func formatSecond(t int) string {
second := t % 60
min := t / 60
secondStr := fmt.Sprintf("%d", second)
if second < 10 {
secondStr = fmt.Sprintf("0%d", second)
}
minStr := fmt.Sprintf("%d", min)
if min < 10 {
minStr = fmt.Sprintf("0%d", min)
}
return fmt.Sprintf("%s:%s", minStr, secondStr)
}
type P2pRtcMessageReq struct {
FromUID string
ToUID string
CallType common.RTCCallType
ResultType common.RTCResultType
Second int
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Bangtsdd/BangLib.git
git@gitee.com:Bangtsdd/BangLib.git
Bangtsdd
BangLib
BangLib
v1.0.9

搜索帮助