In order for your client device to be allowed to receive incoming connections from Twilio, you need to make sure that the Capability Token you've provided allows for it. To do this, you will need to assign a unique client name to your Client and have your server application provide this client name to the incoming capability of the token generator.
In this example, you can see the client name of "joey" is being assigned. When you have multiple clients, this name will need to be unique so that they can each receive calls intended for them.
<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial> <Client>joey</Client> </Dial> </Response>
This will connect the inbound caller with the client application that is registered as "joey." In order to have a conversation, however, the client needs to accept the call.
To accept a call, you only need to listen for the incoming event. That event will pass you a connection object on which you can call the accept() method.
If your arch-enemy is calling and you're just not in the mood to listen to their monologue, you can reject the call. The process is similar to accepting a call except instead of calling the accept() method on the connection object, you call its reject() method.
Calling a Twilio Client using the Twilio REST API is extremely easy as well. It's just like making a PSTN phone call with the REST API, but for the To parameter you specify "client:" followed by the client name you wish to call. Here's an example that calls the client named "tommy."