mirror of
https://github.com/livekit/livekit.git
synced 2026-10-22 15:22:30 +00:00
simple cli with room APIs
This commit is contained in:
1 parent
925d1c653e
commit
9ebfebe2dd
8 files changed
+626
-4
No files matched your search
@@ -3,6 +3,7 @@ package rtc
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrRoomIdMissing = errors.New("roomId is not set")
|
||||
ErrPeerExists = errors.New("peer already exists")
|
||||
ErrPeerNotConnected = errors.New("peer has not been connected")
|
||||
ErrUnsupportedPayloadType = errors.New("peer does not support payload type")
|
||||
|
||||
@@ -28,6 +28,10 @@ func NewRoomForRequest(req *livekit.CreateRoomRequest, config *WebRTCConfig) (*R
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if req.RoomId == "" {
|
||||
return nil, ErrRoomIdMissing
|
||||
}
|
||||
|
||||
return &Room{
|
||||
Room: livekit.Room{
|
||||
RoomId: req.RoomId,
|
||||
|
||||
@@ -35,7 +35,6 @@ func (s *SimpleRoomService) CreateRoom(ctx context.Context, req *livekit.CreateR
|
||||
|
||||
room, err = s.manager.CreateRoom(req)
|
||||
if err != nil {
|
||||
err = twirp.WrapError(twirp.InternalError("could not create room"), err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -45,8 +44,8 @@ func (s *SimpleRoomService) CreateRoom(ctx context.Context, req *livekit.CreateR
|
||||
|
||||
func (s *SimpleRoomService) GetRoom(ctx context.Context, req *livekit.GetRoomRequest) (res *livekit.RoomInfo, err error) {
|
||||
room := s.manager.GetRoom(req.RoomId)
|
||||
if room != nil {
|
||||
err = twirp.NewError(twirp.NotFound, "rooms already exists")
|
||||
if room == nil {
|
||||
err = twirp.NewError(twirp.NotFound, "room does not exist")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user