voximplant / react-native-voximplant

Voximplant mobile SDK for React Native (iOS/Android)
http://voximplant.com
205 stars 39 forks source link

Unable to receive disconnect issues #82

Closed leon2835 closed 5 years ago

leon2835 commented 5 years ago

Hi @YuliaGrigorieva based on issues #79

Is better for me to describe current situation.

let client = Voximplant.getInstance();

1) When Device A use the client.call() to call Device B. (From sdk to Vox cloud, and Vox cloud call Device B by using VoxEngine.callUser(). 2) Device A will show caller screen (Picture CallerScreen), and when Device B received call by using client.on( Voximplant.ClientEvents.IncomingCall, ()=> {console.log("Received incoming call") }) <<<<<<Device B will show incoming screen (Picture IncomingScreen). 3) When Device A call to Device B, Device B reject the call by using call.decline();, Vox scenarios can triggered CallEvents.Failed, and perform action inc.hangup() and VoxEngine.terminate(), so that my Device A can receive "disconnect response" by using call.on(Voximplant.CallEvents.Failed, ()=>{console.log("Call Rejected)} <<<<<<<<<<To close the CallerScreen (Success) 4) But the problem is, when Device A call to Device B, but Device A hangup the call using event.hangup(), Device B was unable to receive any "Disconnect response" in order to close the IncomingScreen. (Problem here)

*Code of receiving call client.on(Voximplant.ClientEvents.IncomingCall, (event) => this._incomingCall(event)); //Receive incoming call (sucess) client.on(Voximplant.ClientEvents.ConnectionClosed, (event) => console.log("Connection Close")); //Unable to retrieve "Disconnect response" client.on(Voximplant.ClientEvents.ConnectionFailed, (event) => console.log("Connection Failed")); //Unable to retrieve "Disconnect response" client.on(Voximplant.CallEvents.Disconnected, (event) => console.log("Call Disconnected")); //Unable to retrieve "Disconnect response" client.on(Voximplant.CallEvents.Failed, (event) => console.log("Call Failed")); //Unable to retrieve "Disconnect response"

*Code of Vox scenario VoxEngine.addEventListener(AppEvents.CallAlerting, e => { var inc = e.call; inc.startEarlyMedia(); inc.say("Welcomne to customer service, please hold a moment.", Language.US_ENGLISH_FEMALE); inc.addEventListener(CallEvents.Disconnected, () => { //Newly added this event listener in order to receive hang up disconnect from Caller (Device A) inc.hangup(); //Using Debug mode will triggered here, just that from Device A, cannot receive any "Disconnect Response" trace("end") VoxEngine.terminate(); }) inc.addEventListener(CallEvents.Failed, () => { trace("end") }) // var out = VoxEngine.callUserDirect(inc, "test1", "379666"); var out = VoxEngine.callUser("test1", "388215", "test2") out.addEventListener(CallEvents.Connected, () => { inc.answer() VoxEngine.sendMediaBetween(inc, out); }); out.addEventListener(CallEvents.Disconnected, () => { trace("end") }); out.addEventListener(CallEvents.Failed, () => { inc.hangup(); trace("end") VoxEngine.terminate(); }); });

Hope that you can understand. Anyway am i missing something? Thank You. CallerScreen

IncomingScreen

YuliaGrigorieva commented 5 years ago

Hello @leon2835 ,

I see several issues in your code snippets from your application code, so I suggest to resolve them and retest the issue.

client.on(Voximplant.ClientEvents.ConnectionClosed, (event) => console.log("Connection Close")); //Unable to retrieve "Disconnect response"
client.on(Voximplant.ClientEvents.ConnectionFailed, (event) => console.log("Connection Failed")); //Unable to retrieve "Disconnect response"

The events ClientEvents.ConnectionClosed and ClientEvents.ConnectionFailed are not related to a call. These events should be use to handle the connection to the Voximplant Cloud close and failure.

client.on(Voximplant.CallEvents.Disconnected, (event) => console.log("Call Disconnected")); //Unable to retrieve "Disconnect response"
client.on(Voximplant.CallEvents.Failed, (event) => console.log("Call Failed")); //Unable to retrieve "Disconnect response"

Here the issue is that you use client to subscribe to CallEvents.Disconnected / CallEvents.Failed. You need to use Call object instead of client as you can subscribe to call events only on the appropriate Call object. To get a Call object you should use one of the following APIs (depend on incoming or outgoing call):

  1. for incoming call:
    client.on(Voximplant.ClientEvents.IncomingCall, (event) => this._incomingCall(event));

    call can be accessed through event object: let call = event.call

  2. outgoing call:
    let call = await client.call(number, callSettings);

After you get a Call instance, you can subscribe to its events the following way:

call.on(Voximplant.CallEvents.Disconnected, .... );
call.on(Voximplant.CallEvents.Failed, ....);

Please check you code and ensure that you have subscribed correctly to the call events and let me know the results.

I also recomment to test your issue with our demo application: https://github.com/voximplant/react-native-demo

Best regards, Yulia Grigorieva

leon2835 commented 5 years ago

Hi @YuliaGrigorieva 1) About the client.on(Voximplant.ClientEvents.ConnectionClosed, (event) => console.log("Connection Close")); //Unable to retrieve "Disconnect response" client.on(Voximplant.ClientEvents.ConnectionFailed, (event) => console.log("Connection Failed")); //Unable to retrieve "Disconnect response" client.on(Voximplant.CallEvents.Disconnected, (event) => console.log("Call Disconnected")); //Unable to retrieve "Disconnect response" client.on(Voximplant.CallEvents.Failed, (event) => console.log("Call Failed")); //Unable to retrieve "Disconnect response" which misunderstanding by me and i already removed the code already.

2) For the 2) outgoing call that you mentioned. I Already done it from step 3, and as i said, i can receive "disconnect response", if Device A make the call to Device B, Device B decline the call, Device A able to receive "disconnect response" with the code of call.on(Voximplant.CallEvents.Disconnected, .... ); call.on(Voximplant.CallEvents.Failed, ....);

3) My only concerned was, if Device A make the call to Device B, when Device b receive incoming call, and Device B screen will automatic show the incoming screen (picture that i provided from original post). However if Device A cancel the outgoing call, Device B was unable to receive "disconnect response" due to Device B only have the code of : client.on(Voximplant.ClientEvents.IncomingCall, (event) => this._incomingCall(event)); I already search from the documentation that Vox provided, but still unable to find any information about how to trigger "Disconnect response" like:

client.on("Disconnect or failed or some similar event", (event) => ...........);

Thank You.

YuliaGrigorieva commented 5 years ago

Hello @leon2835 ,

You need to subscribe to Voximplant.CallEvents.Disconnected event on Device B side. This event should be invoked if Device A cancel outgoing call via Call.hangup API:

incomingCall.on(Voximplant.CallEvents.Disconnected, .... );

where incomingCall is taken from Voximplant.ClientEvents.IncomingCall, i.e. let call = event.call.

If you provide the code snippets of how you handle and process incoming call, I can provide you the fix for this issue.

Best regards, Yulia Grigorieva

leon2835 commented 5 years ago

Hi @YuliaGrigorieva Thanks for your advise, Device B was able to received "Disconnect response" When device A make the call and cancel the call with this line of code that I highlight below:

Below are the code for Device A & B: When Making Call const callSettings = { video: { sendVideo: false, receiveVideo: false, } }; // create and start a call let call = await client.call("test1", callSettings); call.on(Voximplant.CallEvents.Connected, (event) => this._onCallConnected(event)); call.on(Voximplant.CallEvents.Disconnected, () => console.log("call disconnect")) call.on(Voximplant.CallEvents.Failed, () => this.logout())

*When receive incoming call client.on(Voximplant.ClientEvents.IncomingCall, (event) => this._incomingCall(event));

_incomingCall(event) { console.log("Incoming") let a = event.call a.on(Voximplant.ClientEvents.ConnectionClosed, ()=>{console.log("Connection Closed")}) a.on(Voximplant.ClientEvents.ConnectionFailed, ()=>{console.log("Connection Failed")}) a.on(Voximplant.ClientEvents.Failed, ()=>{console.log("Connection Failed")}) this.setState({ showModal: true, event: event })

a.on(Voximplant.CallEvents.Disconnected, ()=>{console.log("Connection Disconnect")})

}

Thank You very much. :) Issues solved.

YuliaGrigorieva commented 5 years ago

Hello @leon2835 ,

I'm glad that the issue is resolved.

I would like to pay your attention to these lines of code from your code snippet:

a.on(Voximplant.ClientEvents.ConnectionClosed, ()=>{console.log("Connection Closed")})
a.on(Voximplant.ClientEvents.ConnectionFailed, ()=>{console.log("Connection Failed")})

These events will never be invoked, because these are Client events and you subscribe to them on a call object. You should use client instead a and probably move this code to another place.

Here I believe you have a typo:

a.on(Voximplant.ClientEvents.Failed, ()=>{console.log("Connection Failed")})

It should be:

a.on(Voximplant.CallEvents.Failed, ()=>{console.log("Connection Failed")})

I'm closing this issue now as the original problem is resolved. Please open a new one if you have any questions or face any issues.

Best regards, Yulia Grigorieva