How to terminate Voximplant session correctly? - voximplant

How do I terminate a Voximplant session after a call? Do I do this way:
outgoing.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);
Or this way: VoxEngine.terminate.bind(VoxEngine)?

The first variant is correct. Alternatively, the session automatically terminates a minute after the call ends.

Related

How long does it take Voximplant to detect a disconnected user?

I am testing losing connection in a Voximplant call. The Disconnected event fires after approximately one minute after losing connection. Can I adjust this value?
The server waits for the client to reconnect if the connection is lost. If you don't need this feature, you can send pings from the client via sendMessage and check for them for example each 2-3 seconds. If there are no pings, then use hangup

Only one callback at a time - WCF limitation?

I stuck on this one for about two weeks now - So could someone tell me, is there a limitation from WCF that only one callback at a time can be handled by a callback object? I have tried just about anything I can find in trying to resolve this issue still can't get any place.
I created a very simple app: a client invokes a service then the service makes two callbacks to the client at the same time: callback A, which takes a long time to return; then callback B, calls back repeatedly in a loop even when A is in processing. The problem is, B will never get through when A is in processing. But as soon as A returns, B will get through right away.
Here are the things I have tried:
1. Set ConcurrencyMode to Multiple or Reentrant on both client and service;
2. Set UseSynchronizationContext to False on both client and service;
3. Start service invocation from a worker thread on the client;
4. Creates proxy (service channel) on a worker thread on the client;
5. Start both callbacks on their own worker thread on the service;
6. Making both callbacks as Oneway.
None of these solved issue. The only thing I can think now is that this may be a limitation from WCF. So if someone can shed some light on this it will be greatly appreciated.
Could you try to make an async proxy? When you left click on you're project then clic add Service Reference, then check Generate asynchronous operations.
You will have a client that use event to callback returns. And if I'm not wrong, each callback are done in different threads.

Replacing a call to sleep when waiting on an NSStream response

I made an application which uses NSStream to etablish a connection to a telnet server.
When the connection is made, I send a first command. Then I use sleep(1); to make my application wait. Then the second command is sent.
The problem is that the entire GUI is stuck during the sleep(). I know that it's not the "perfect" way to make a "pause" and I'd like to learn how to this properly. I heard good things about NSTimer but I'd like to have a concrete and "easy" way of using it, to simply replace my poor use of sleep().
You should be able to register some kind of callback with whatever procedure you're using to establish the connection. Just let your code wait for that callback without doing anything at all.
In this case, using NSStream, you need to schedule the stream on the run loop:
[stream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
The run loop is the construct that processes events for your application. When you use sleep(), it is stopped, and your GUI can't do anything. By adding the stream as input to the run loop, you allow them both to continue to work.
You also must set a delegate object ([stream setDelegate:self];, e.g.) which will recieve notifications when the stream has something to report. That delegate must implement stream:handleEvent:, which will be called with a reference to the stream and a code indicating what happened.

Best practice: NSURLConnection sendSynchronousRequest vs sendAsynchronousRequest

Is it best to send a synchronous or an asynchronous request?
I'm sending a request to a server, asking for a list of files, which I would like the user to choose from.
Synchronous request does stop the application from any user action until it completes, because it runs in the main thread.
Asynchronous does not as it runs in other thread.
You should always use asynchronous requests as they do not block the thread they are called from. Instead they will call your delegate methods when the connection fails or succeeds. If you need to prevent the user from doing anything while the connection is running, use a HUD class like MBProgressHUD (check github).
You'd want to use asynchronous calls when you're calling from the Main Thread. Otherwise, the whole user interface will become unresponsive (i.e: freeze) until the server responds. (The user interface in maintained by the main thread).
You'd want to use synchronous calls when you're calling from another thread and you want it to wait until it has the response before continuing. If you've manually created a thread, calling asynchronous from this new thread would create a third thread.
Asynchronous means the "calling body" won't wait until the task is done.

WCF - What is the difference between Binding.RecieveTimeout and Binding.ReliableSession.InactivityTimeout?

In WCF, what is the difference between Binding.RecieveTimeout and Binding.ReliableSession.InactivityTimeout?
From http://blogs.msdn.com/drnick/archive/2007/06/26/session-lifetime-on-the-server.aspx
When using a reliable session, there are two different inactivity timers that must be satisfied to keep the connection alive. If either inactivity timer goes off, then the connection is killed.
The first inactivity timer is on the reliable session and is called InactivityTimeout. This inactivity timer fires if no messages, either application or infrastructure, are received within the timeout period. An infrastructure message is a message that is generated for the purpose of one of the protocols in the channel stack, such as a keep alive or an acknowledgment, rather than containing application data.
The second inactivity timer is on the service and uses the ReceiveTimeout setting of the binding. This inactivity timer fires if no application messages are received within the timeout period.