mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 11:06:43 +08:00
grpc version
This commit is contained in:
parent
a5f831e81e
commit
bae5042eea
@ -1,12 +1,7 @@
|
|||||||
package open_im_media
|
package open_im_media
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
lksdk "github.com/livekit/server-sdk-go"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/livekit/protocol/auth"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -15,7 +10,7 @@ const (
|
|||||||
ApiSecret = "23ztfSqsfQ8hKkHzHTl3Z4bvaxro0snjk5jwbp5p6Q3"
|
ApiSecret = "23ztfSqsfQ8hKkHzHTl3Z4bvaxro0snjk5jwbp5p6Q3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var roomClient *lksdk.RoomServiceClient
|
//var roomClient *lksdk.RoomServiceClient
|
||||||
|
|
||||||
type Media struct {
|
type Media struct {
|
||||||
MediaAddress string
|
MediaAddress string
|
||||||
@ -32,26 +27,28 @@ func (m *Media) GetUrl() string {
|
|||||||
return m.MediaAddress
|
return m.MediaAddress
|
||||||
}
|
}
|
||||||
func (m *Media) GetJoinToken(room, identity string) (string, error) {
|
func (m *Media) GetJoinToken(room, identity string) (string, error) {
|
||||||
at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
|
return identity, nil
|
||||||
grant := &auth.VideoGrant{
|
//at := auth.NewAccessToken(m.ApiKey, m.ApiSecret)
|
||||||
RoomJoin: true,
|
//grant := &auth.VideoGrant{
|
||||||
Room: room,
|
// RoomJoin: true,
|
||||||
}
|
// Room: room,
|
||||||
at.AddGrant(grant).
|
//}
|
||||||
SetIdentity(identity).
|
//at.AddGrant(grant).
|
||||||
SetValidFor(time.Hour)
|
// SetIdentity(identity).
|
||||||
|
// SetValidFor(time.Hour)
|
||||||
return at.ToJWT()
|
//
|
||||||
|
//return at.ToJWT()
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
roomClient = lksdk.NewRoomServiceClient(MediaAddress, ApiKey, ApiSecret)
|
//roomClient = lksdk.NewRoomServiceClient(MediaAddress, ApiKey, ApiSecret)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Media) CreateRoom(roomName string) (*livekit.Room, error) {
|
func (m *Media) CreateRoom(roomName string) (*livekit.Room, error) {
|
||||||
return roomClient.CreateRoom(context.Background(), &livekit.CreateRoomRequest{
|
return nil, nil
|
||||||
Name: roomName,
|
//return roomClient.CreateRoom(context.Background(), &livekit.CreateRoomRequest{
|
||||||
EmptyTimeout: 60 * 3,
|
// Name: roomName,
|
||||||
})
|
// EmptyTimeout: 60 * 3,
|
||||||
|
//})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user