// Start is called before the first frame update public void initiate() { DontDestroyOnLoad(this); UnityThread.initUnityThread(); ClientHandleData.InizializzaPacchetti(); ClientTcp.InizializzaNetwork(); }
private static void ReceiveCallBack(IAsyncResult result) { try { int length = myStream.EndRead(result); if (length <= 0) { return; } byte[] newbytes = new byte[length]; Array.Copy(recBuffer, newbytes, length); UnityThread.executeInFixedUpdate(() => { ClientHandleData.HandleData(newbytes); }); myStream.BeginRead(recBuffer, 0, 4096 * 2, ReceiveCallBack, null); } catch (Exception) { Debug.Log("Error!"); } }