Commit b08e0e14 authored by hujiebin's avatar hujiebin
parents 7e5aef74 0faeb828
...@@ -2,12 +2,14 @@ package rpc ...@@ -2,12 +2,14 @@ package rpc
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"git.hilo.cn/hilo-common/_const/enum/timezone_e" "git.hilo.cn/hilo-common/_const/enum/timezone_e"
"git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus" "git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/consul" "git.hilo.cn/hilo-common/resource/consul"
"git.hilo.cn/hilo-common/resource/mysql" "git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/utils"
"math/rand" "math/rand"
) )
...@@ -190,3 +192,36 @@ func getGroupHost() string { ...@@ -190,3 +192,36 @@ func getGroupHost() string {
mylogrus.MyLog.Infof("getHostGroup:%v---%v", r, groupServerHost[r]) mylogrus.MyLog.Infof("getHostGroup:%v---%v", r, groupServerHost[r])
return groupServerHost[r] return groupServerHost[r]
} }
// 上麦
func MicIn(model *domain.Model, groupId, token string) error {
defer utils.CheckGoPanic()
type MicInResp struct {
Code int `json:"code"`
Data struct {
MicIndex int `json:"micIndex"`
} `json:"data"`
}
_url := fmt.Sprintf("%v://%v/v1/imGroup/mic/in", defaultGroupServerScheme, getGroupHost())
header := map[string]string{
"token": token,
}
resp, err := HttpPostForm(model, _url, header, map[string]string{
"groupUuid": groupId,
"i": "", // 空则随意上一个空位置
})
if err != nil {
model.Log.Errorf("MicIn fail:%v", err)
return err
}
response := new(MicInResp)
if err = json.Unmarshal(resp, response); err != nil {
model.Log.Errorf("MicIn json fail:%v", err)
return err
}
if response.Code != 200 {
model.Log.Errorf(fmt.Sprintf("Mic In Not 200:%v,groupId:%v", response, groupId))
return errors.New(fmt.Sprintf("Mic In Not 200:%v", response))
}
return nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment