I can not call methods (for example SendMessage) from onDisconnectDone. I always get an exception like this: Can only be called from the main thread ... There is no such problem on onConnectDone. A small sample code (Unity 2017.4.0f1):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using com.shephertz.app42.gaming.multiplayer.client;
using com.shephertz.app42.gaming.multiplayer.client.events;
using com.shephertz.app42.gaming.multiplayer.client.command;
using com.shephertz.app42.gaming.multiplayer.client.listener;
public class WarpTest : MonoBehaviour, ConnectionRequestListener
{
public string apiKey = "<apiKey>";
public string pvtKey = "<pvtKey>";
void OnWarpConnect ()
{
print ("Warp Connect!");
}
void OnWarpDisconnect ()
{
print ("Warp Disconnect!");
}
public void onConnectDone (ConnectEvent eventObj)
{
this.SendMessage ("OnWarpConnect", null, SendMessageOptions.DontRequireReceiver);
}
public void onDisconnectDone (ConnectEvent eventObj)
{
this.SendMessage ("OnWarpDisconnect", null, SendMessageOptions.DontRequireReceiver);
// ERROR!
}
public void onInitUDPDone (byte resultCode) { }
// Use this for initialization
void Awake () {
WarpClient.initialize (this.apiKey, this.pvtKey);
WarpClient.GetInstance ().AddConnectionRequestListener (this);
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.C)) WarpClient.GetInstance ().Connect ("Player");
if (Input.GetKeyDown (KeyCode.D)) WarpClient.GetInstance ().Disconnect ();
}
}