/// <inheritdoc />
        public async Task RedirectAsync()
        {
            await new UnityYieldAwaitable();

            await ConnectionService.DisconnectAsync(0);

            GameNetworkClient client = ComponentAttachmentFactory.AddTo <GameNetworkClient>(new GameObject("Runtime Redirected NetworkClient"));

            //This is kinda hack, but we need to wait for Awake to run.
            await new UnityYieldAwaitable();

            //It's important we connect THROUGH this client, not the connection service so that
            //it starts the network thread
            await client.ConnectAsync(ConnectionDetails.IpAddress, ConnectionDetails.Port);
        }
Esempio n. 2
0
        public void SwitchZoneInstances()
        {
            //Make it so that we can only fire 1 instance change
            if (wasFired)
            {
                return;
            }

            wasFired = true;

            //Just load
            int zoneId = Int32.Parse(Input.text);

            ConnectionService.DisconnectAsync(0)
            .UnityAsyncContinueWith(this, () => OnFinishedDisconnecting(zoneId))
            .ConfigureAwait(false);

            //We can't await to unwrap exceptions because
            //the other thing joins the unity3d main thread via synccontext hack
            //and therefore will deadlock
        }