mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-14 05:56:00 +08:00
pb modify
This commit is contained in:
@@ -5,13 +5,11 @@ import (
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/jinzhu/copier"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
const (
|
||||
MediaAddress = "ws://43.128.5.63:7880"
|
||||
ApiKey = "APIGPW3gnFTzqHH"
|
||||
ApiSecret = "23ztfSqsfQ8hKkHzHTl3Z4bvaxro0snjk5jwbp5p6Q3"
|
||||
// Address gRPC服务地址
|
||||
Address = "127.0.0.1:11300"
|
||||
)
|
||||
@@ -19,36 +17,30 @@ const (
|
||||
//var roomClient *lksdk.RoomServiceClient
|
||||
|
||||
type Media struct {
|
||||
MediaAddress string
|
||||
ApiKey string
|
||||
ApiSecret string
|
||||
}
|
||||
|
||||
func NewMedia() *Media {
|
||||
return &Media{MediaAddress: MediaAddress,
|
||||
ApiKey: ApiKey,
|
||||
ApiSecret: ApiSecret}
|
||||
}
|
||||
func (m *Media) GetUrl() string {
|
||||
return m.MediaAddress
|
||||
return &Media{}
|
||||
}
|
||||
|
||||
func (m *Media) GetJoinToken(room, identity string, operationID string, data *open_im_sdk.ParticipantMetaData) (string, error) {
|
||||
func (m *Media) GetJoinToken(room, identity string, operationID string, data *open_im_sdk.ParticipantMetaData) (string, string, error) {
|
||||
var newData pbRtc.ParticipantMetaData
|
||||
copier.Copy(&newData, data)
|
||||
conn, err := grpc.Dial(Address, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", "", err
|
||||
}
|
||||
defer conn.Close()
|
||||
c := pbRtc.NewRtcServiceClient(conn)
|
||||
req := &pbRtc.GetJoinTokenReq{ApiKey: m.ApiKey, ApiSecret: m.ApiSecret, Room: room, OperationID: operationID, Identity: identity, MetaData: data}
|
||||
req := &pbRtc.GetJoinTokenReq{Room: room, OperationID: operationID, Identity: identity, MetaData: &newData}
|
||||
resp, err := c.GetJoinToken(context.Background(), req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", "", err
|
||||
}
|
||||
if resp.CommonResp.ErrCode != 0 {
|
||||
return "", errors.New(resp.CommonResp.ErrMsg)
|
||||
return "", "", errors.New(resp.CommonResp.ErrMsg)
|
||||
}
|
||||
return resp.Jwt, nil
|
||||
return resp.Jwt, resp.LiveURL, nil
|
||||
//at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
|
||||
//grant := &auth.VideoGrant{
|
||||
// RoomJoin: true,
|
||||
|
||||
Reference in New Issue
Block a user