change and check error message

This commit is contained in:
aler9
2022-10-28 15:28:05 +02:00
parent c51fddc784
commit 630b1ebce1
3 changed files with 8 additions and 2 deletions

View File

@@ -242,7 +242,7 @@ type ErrServerUDPPortsAlreadyInUse struct {
// Error implements the error interface.
func (e ErrServerUDPPortsAlreadyInUse) Error() string {
return fmt.Sprintf("UDP ports %d and %d are already in use by another reader",
return fmt.Sprintf("UDP ports %d and %d are already assigned to another reader",
e.Port, e.Port+1)
}

View File

@@ -289,9 +289,15 @@ func TestServerReadSetupErrorSameUDPPorts(t *testing.T) {
stream := NewServerStream(Tracks{track})
defer stream.Close()
first := int32(1)
s := &Server{
Handler: &testServerHandler{
onConnClose: func(ctx *ServerHandlerOnConnCloseCtx) {
if atomic.SwapInt32(&first, 0) == 1 {
require.EqualError(t, ctx.Error, "UDP ports 35466 and 35467 are already assigned to another reader")
}
},
onSetup: func(ctx *ServerHandlerOnSetupCtx) (*base.Response, *ServerStream, error) {
return &base.Response{
StatusCode: base.StatusOK,

View File

@@ -123,7 +123,7 @@ func (st *ServerStream) readerAdd(
return fmt.Errorf("stream is closed")
}
// check whether UDP ports are already in use by another reader
// check whether UDP ports are already assigned to another reader
if transport == TransportUDP {
for r := range st.readers {
if *r.setuppedTransport == TransportUDP &&