I am using Appwarp api for a multiplayer game. I am getting an error when i am calling Invoke("recoverConnection", 5)
.
public void onConnectDone(ConnectEvent eventObj)
{
Log ("onConnectDone : " + eventObj.getResult ());
if (eventObj.getResult () == 0)
{
recoveryErrorCode = 0;
WarpClient.GetInstance ().JoinRoomInRange (0, 5, true);
}
else if (eventObj.getResult () == 9)
{
this.Invoke("recoverConnection", 5);
}
else if (eventObj.getResult () == 8)
{
// reconnected
}
}
void recoverConnection()
{
WarpClient.GetInstance ().RecoverConnection ();
}
The error is :
Invoke can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.