# Can't send signal to specific user

**URL:** <https://openvidu.discourse.group/t/cant-send-signal-to-specific-user/3919>\
**Category:** How to implement?\
**Tags:** v2\
**Created:** [April 23, 2022, 5:15pm UTC](https://openvidu.discourse.group/t/cant-send-signal-to-specific-user/3919 "2022-04-23T17:15:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Developer3010](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@Developer3010](https://openvidu.discourse.group/u/Developer3010)\
**Post date:** [April 23, 2022, 5:15pm UTC](https://openvidu.discourse.group/t/cant-send-signal-to-specific-user/3919/1 "2022-04-23T17:15:42Z")

</div>

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?

```auto
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.

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [April 25, 2022, 10:03am UTC](https://openvidu.discourse.group/t/cant-send-signal-to-specific-user/3919/2 "2022-04-25T10:03:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Developer3010](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@Developer3010](https://openvidu.discourse.group/u/Developer3010)\
**Post date:** [April 26, 2022, 10:50am UTC](https://openvidu.discourse.group/t/cant-send-signal-to-specific-user/3919/3 "2022-04-26T10:50:44Z")

</div>

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.
