switch to twirp errors, correct RTC port
This commit is contained in:
+5
-3
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/google/wire"
|
||||
"github.com/pion/stun"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/proto"
|
||||
)
|
||||
|
||||
@@ -26,14 +27,15 @@ type NodeStats struct {
|
||||
BytesPerMin int64
|
||||
}
|
||||
|
||||
func NewLocalNode() (*Node, error) {
|
||||
func NewLocalNode(conf *config.Config) (*Node, error) {
|
||||
id, err := uuid.NewRandom()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n := &Node{
|
||||
proto.Node{
|
||||
Id: id.String(),
|
||||
Node: proto.Node{
|
||||
Id: id.String(),
|
||||
RtcPort: conf.RTCPort,
|
||||
},
|
||||
}
|
||||
if err = n.DiscoverNetworkInfo(); err != nil {
|
||||
|
||||
@@ -4,8 +4,7 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"github.com/twitchtv/twirp"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/node"
|
||||
"github.com/livekit/livekit-server/proto"
|
||||
@@ -33,7 +32,7 @@ func (s *SimpleRoomService) CreateRoom(ctx context.Context, req *proto.CreateRoo
|
||||
defer s.roomLock.Unlock()
|
||||
|
||||
if s.rooms[req.Room] {
|
||||
err = status.Errorf(codes.AlreadyExists, "room %s already exists", req.Room)
|
||||
err = twirp.NewError(twirp.AlreadyExists, "room already exists")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ func (s *SimpleRoomService) CreateRoom(ctx context.Context, req *proto.CreateRoo
|
||||
|
||||
func (s *SimpleRoomService) JoinRoom(ctx context.Context, req *proto.JoinRoomRequest) (res *proto.JoinRoomResponse, err error) {
|
||||
if !s.rooms[req.Room] {
|
||||
err = status.Errorf(codes.NotFound, "room %s does not exist", req.Room)
|
||||
err = twirp.NewError(twirp.AlreadyExists, "the room does not exist")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user