代码拉取完成,页面将自动刷新
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
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。