Can't send signal to specific user

Hi everyone, on the guide I read that it is possible to send signals to a single user instead of using broadcast messages.

I tried to implement the solution, but all users continue to receive the signal even though I have set the “to: [” connectionID “]” as described in the guide.

I leave my code below, can someone tell me what am I wrong?

myFunction()
{
    if(this.participantsNameList.length > 0)
    {
        var sReceivers = '';

        // Ciclo i partecipanti per ottenre il numero di admin totale.

        for(var i = 0; i < this.participantsNameList.length; i++)
        {
            if(this.participantsNameList[i].nickname.includes('_admin'))
            {
                if(sReceivers != '')
                {
                    sReceivers += ',';
                }

                sReceivers += this.participantsNameList[i].connectionId;
            }
        }

        if(sReceivers != '')
        {
            const dData = 
            {
                message: 'test-message'
            };
            
            this.mySignalFunction(dData, 'dd-command-test-message', JSON.stringify(sReceivers));
        }
    }
}

mySignalFunction(dUserData: any, sSignalType: string, sReceivers: any = '')
{
    const sessionAvailable = this.openViduWebRTCService.getSessionOfUserConnected();

    sessionAvailable.signal
    ({
        to: [sReceivers],
        data: JSON.stringify(dUserData),
        type: sSignalType
    });
}

Many thanks in advance.

You have to carefully go through your sReceivers parameter, because your function expects a string value but the to parameter must be an array of strings. I mean: I have the feeling you are building something like this:
['connectionId1,connecyionId2,connectionId3'], which is not the same as this: ['connectionId1','connecyionId2','connectionId3']. Besides, in myFunction you start with a string parameter (var sReceivers = ''), and at the end you are calling JSON.stringify(sReceivers) ?? I don’t think it make sense trying to stringify a string paramter, do you?

I agree with you Pablo, but I changed my code about ten times, first passing an array, but the array was built with ’ and not with " as required by the “TO” parameter and consequently everyone received the signal, then I tried to use the JSON.stringify which allows you to have an array with " and not with ', but that also didn’t work, so my last solution was to pass a string with " and put it inside the [] of the parameter “TO”, but that didn’t work either.

My first result was like this ['connectionId1','connecyionId2','connectionId3'] but it didn’t work.
How am I supposed to make this thing work?

Thanks a lot, Matteo.