[BUG] - streamerIDOption.selected returns an array. Not a string #489
Description
UE Version:
UE 5.4
Frontend Version:
UE5.4-0.0.3
Problem component
Frontend
Description
I want to continue the topic raised here
Tested the ability to connect several streamers to one signal server, without using a matchmaker. An array of available streamers comes to the client via a web socket, and everything is cool here.
The problem appears when selecting a streamer during initial setup.
initialSettings: {
StreamerId: 'DefaultStreamer1'
}
The StreamerId parameter is not accepted in the PixelStreaming class and no connection to the streamer occurs.
This only works if you specify the /?StreamerId=DefaultStreamer1 parameter via the URL
Updating In SettingOption.ts in the constructor
super(id, label, description, [defaultTextValue], defaultOnChangeListener);
to
super(id, label, description, defaultTextValue, defaultOnChangeListener);
fixed this issue (Thanks @mcottontensor)
Steps to Reproduce:
- Clone React example and pass StreamerId: 'DefaultStreamer1' (or your streamer's name) option to Config
- Run two streamers on the same 8888 ports
- Start the signalling web server and configure it to listen two streamers on the 8888. Only one signaling server required!
- Try connecting to the stream from the client (You won`t succeed)
- At this point go to WebRtcPlayerController.ts -> handleStreamerListMessage method and try to log streamerIDOption.selected.
As mentioned in SettingsOption.ts selected() getter must return a string. But here it is an array of strings. Typescript won't tell you the error, you have to check the console. Because of this, the condition does not work correctly and the wanted streamer is not assigned to a variable
Here is a piece of code from WebRtcPlayerController.handleStreamerListMessage()
//Oh, why is there var here???
var streamerIDOption = this.config.getSettingOption(OptionParameters.StreamerId); // <-- Here is an array !!
const existingSelection = streamerIDOption.selected.toString().trim(); // <-- Here is a string. Its ok
if (!!existingSelection) { // <-- Cool, we're inside an if statement
// default to selected option if it exists
wantedStreamerId = streamerIDOption.selected; // <-- OMG. Here is an array !!
}
....
....
// (sh*t, here is an array) conditions go wrong
if (wantedStreamerId && messageStreamerList.ids.includes(wantedStreamerId)) {
// if the wanted stream is in the list. we pick that <-- (will be cool, but ['Streamer', 'Streamer1'].includes(['Streamer']) returns false)
autoSelectedStreamerId = wantedStreamerId;
This also doesn't work correctly if there is only one streamer but with a specified StreamerId on the client.
Expected behavior
- The stream must run through the selected StreamerID.
Platform (please complete the following information):
- OS: Ubuntu Desktop 22.04.3 LTS
- Chrome Version 121.0.6167.160 (Official Build) (64-bit)
P.S. Many thanks for your hard work. You've created a really great library.