diff --git a/cmd/signal/grpc/server/server.go b/cmd/signal/grpc/server/server.go index 1d02dd9eb..ef4f2676e 100644 --- a/cmd/signal/grpc/server/server.go +++ b/cmd/signal/grpc/server/server.go @@ -79,26 +79,6 @@ func (s *SFUServer) Signal(stream pb.SFU_SignalServer) error { } } - answer, err := peer.Join(payload.Join.Sid, offer) - if err != nil { - switch err { - case sfu.ErrTransportExists: - fallthrough - case sfu.ErrOfferIgnored: - err = stream.Send(&pb.SignalReply{ - Payload: &pb.SignalReply_Error{ - Error: fmt.Errorf("join error: %w", err).Error(), - }, - }) - if err != nil { - log.Errorf("grpc send error %v ", err) - return status.Errorf(codes.Internal, err.Error()) - } - default: - return status.Errorf(codes.Unknown, err.Error()) - } - } - // Notify user of new ice candidate peer.OnIceCandidate = func(candidate *webrtc.ICECandidateInit, target int) { bytes, err := json.Marshal(candidate) @@ -156,6 +136,26 @@ func (s *SFUServer) Signal(stream pb.SFU_SignalServer) error { } } + answer, err := peer.Join(payload.Join.Sid, offer) + if err != nil { + switch err { + case sfu.ErrTransportExists: + fallthrough + case sfu.ErrOfferIgnored: + err = stream.Send(&pb.SignalReply{ + Payload: &pb.SignalReply_Error{ + Error: fmt.Errorf("join error: %w", err).Error(), + }, + }) + if err != nil { + log.Errorf("grpc send error %v ", err) + return status.Errorf(codes.Internal, err.Error()) + } + default: + return status.Errorf(codes.Unknown, err.Error()) + } + } + marshalled, err := json.Marshal(answer) if err != nil { return status.Errorf(codes.Internal, fmt.Sprintf("sdp marshal error: %v", err)) diff --git a/go.sum b/go.sum index c3aefc878..80951f747 100644 --- a/go.sum +++ b/go.sum @@ -516,6 +516,7 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=