mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-20 16:59:01 +08:00
pb modify
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
package open_im_media
|
||||
|
||||
import (
|
||||
pbRtc "Open_IM/pkg/proto/rtc"
|
||||
"context"
|
||||
"errors"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
const (
|
||||
MediaAddress = "ws://43.128.5.63:7880"
|
||||
ApiKey = "APIGPW3gnFTzqHH"
|
||||
ApiSecret = "23ztfSqsfQ8hKkHzHTl3Z4bvaxro0snjk5jwbp5p6Q3"
|
||||
// Address gRPC服务地址
|
||||
Address = "127.0.0.1:11300"
|
||||
)
|
||||
|
||||
//var roomClient *lksdk.RoomServiceClient
|
||||
@@ -22,8 +31,23 @@ func NewMedia() *Media {
|
||||
func (m *Media) GetUrl() string {
|
||||
return m.MediaAddress
|
||||
}
|
||||
func (m *Media) GetJoinToken(room, identity string) (string, error) {
|
||||
return identity, nil
|
||||
|
||||
func (m *Media) GetJoinToken(room, identity string, operationID string) (string, error) {
|
||||
conn, err := grpc.Dial(Address, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer conn.Close()
|
||||
c := pbRtc.NewRtcServiceClient(conn)
|
||||
req := &pbRtc.GetJoinTokenReq{ApiKey: m.ApiKey, ApiSecret: m.ApiSecret, Room: room, OperationID: operationID, Identity: identity}
|
||||
resp, err := c.GetJoinToken(context.Background(), req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if resp.CommonResp.ErrCode != 0 {
|
||||
return "", errors.New(resp.CommonResp.ErrMsg)
|
||||
}
|
||||
return resp.Jwt, nil
|
||||
//at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
|
||||
//grant := &auth.VideoGrant{
|
||||
// RoomJoin: true,
|
||||
|
||||
Reference in New Issue
Block a user