Asynchronous method calls
Learn how asynchronous methods work in Vivox Unreal.
Read time 1 minuteLast updated 2 days ago
There are a number of methods in the Vivox Core Unreal 4 plug-in that complete asynchronously. As a matter of convention, any method that completes asynchronously has the method name prefixed with “Begin”. Also, the last argument to the method is always the delegate that is called when the method completes. If an asynchronous method immediately returns 0, the delegate is guaranteed to be called. If an asynchronous method immediately returns a non-zero number, the delegate is guaranteed to not be called. There is no need for the game to implement a timer to guarantee the completion of asynchronous method calls. The following code displays an example of a typical asynchronous method call:
ILoginSession::FOnBeginLoginCompletedDelegate theDelegate;theDelegate.BindLambda([this]VivoxCoreError error){ if(error != VxErrorSuccess) { UE_LOG(VivoxCore, Error, TEXT("ILoginSession.BeginLogin() returned %d"), error); } else { UE_LOG(VivoxCore, Display, TEXT("ILoginSession.BeginLogin() returned %d"), error); }});login.BeginLogin(kDefaultServer, login.GetLoginToken(kDefaultKey, kDefaultExpiration),theDelegate);