diff --git a/rpc/group.go b/rpc/group.go index 8b7997a2e29a09747760ebcf9ebdb64fcf20f284..14a96d69f2d0743a8fb3e2089c834581eaf861d8 100644 --- a/rpc/group.go +++ b/rpc/group.go @@ -2,12 +2,14 @@ package rpc import ( "encoding/json" + "errors" "fmt" "git.hilo.cn/hilo-common/_const/enum/timezone_e" "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/mylogrus" "git.hilo.cn/hilo-common/resource/consul" "git.hilo.cn/hilo-common/resource/mysql" + "git.hilo.cn/hilo-common/utils" "math/rand" ) @@ -190,3 +192,36 @@ func getGroupHost() string { mylogrus.MyLog.Infof("getHostGroup:%v---%v", r, 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 +}