private async void Start()
        {
            var connParams = CreateConnectionParameters(WorkerType);

            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(connParams);

            if (!Application.isEditor)
            {
                var initializer = new CommandLineConnectionFlowInitializer();
                switch (initializer.GetConnectionService())
                {
                case ConnectionService.Receptionist:
                    builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerType), initializer));
                    break;

                case ConnectionService.Locator:
                    builder.SetConnectionFlow(new LocatorFlow(initializer));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else
            {
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerType)));
            }

            await Connect(builder, new ForwardingDispatcher()).ConfigureAwait(false);
        }
示例#2
0
        protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
        {
            var connParams = CreateConnectionParameters(WorkerUtils.MobileClient);

            connParams.Network.UseExternalIp  = true;
            connParams.Network.ConnectionType = NetworkConnectionType.ModularKcp;

            var initializer = new MobileConnectionFlowInitializer(
                new MobileConnectionFlowInitializer.CommandLineSettingsProvider(),
                new MobileConnectionFlowInitializer.PlayerPrefsSettingsProvider(),
                this);

            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(connParams);

            switch (initializer.GetConnectionService())
            {
            case ConnectionService.Receptionist:
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.MobileClient),
                                                               initializer));
                break;

            case ConnectionService.Locator:
                builder.SetConnectionFlow(new LocatorFlow(initializer));
                break;

            default:
                throw new ArgumentException("Received unsupported connection service.");
            }

            return(builder);
        }
        public async void Start()
        {
            var connParams = CreateConnectionParameters(WorkerType, new MobileConnectionParametersInitializer());

            var flowInitializer = new MobileConnectionFlowInitializer(
                new MobileConnectionFlowInitializer.CommandLineSettingsProvider(),
                new MobileConnectionFlowInitializer.PlayerPrefsSettingsProvider(),
                this);

            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(connParams);

            switch (flowInitializer.GetConnectionService())
            {
            case ConnectionService.Receptionist:
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerType),
                                                               flowInitializer));
                break;

            case ConnectionService.Locator:
                builder.SetConnectionFlow(new LocatorFlow(flowInitializer));
                break;

            default:
                throw new ArgumentException("Received unsupported connection service.");
            }

            await Connect(builder, new ForwardingDispatcher()).ConfigureAwait(false);
        }
        protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
        {
            var connectionParams = new ConnectionParameters
            {
                DefaultComponentVtable = new ComponentVtable(),
                WorkerType             = WorkerUtils.UnityClient
            };

            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(connectionParams);

            if (UseSessionFlow)
            {
                connectionParams.Network.UseExternalIp = true;
                builder.SetConnectionFlow(new ChosenDeploymentAlphaLocatorFlow(deployment,
                                                                               new SessionConnectionFlowInitializer(new CommandLineConnectionFlowInitializer())));
            }
            else if (Application.isEditor)
            {
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient)));
            }
            else
            {
                var initializer = new CommandLineConnectionFlowInitializer();

                switch (initializer.GetConnectionService())
                {
                case ConnectionService.Receptionist:
                    var rec = new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient),
                                                   initializer);

                    connectionParams.Network.UseExternalIp = true;
                    rec.ReceptionistHost = "192.168.20.238";

                    builder.SetConnectionFlow(rec);
                    break;

                case ConnectionService.Locator:
                    connectionParams.Network.UseExternalIp = true;
                    var loc = new LocatorFlow(initializer);
                    builder.SetConnectionFlow(loc);
                    break;

                case ConnectionService.AlphaLocator:
                    connectionParams.Network.UseExternalIp = true;
                    builder.SetConnectionFlow(new AlphaLocatorFlow(initializer));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(builder);
        }
        protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
        {
            var connParams = CreateConnectionParameters(WorkerUtils.MobileClient);

            connParams.Network.UseExternalIp  = true;
            connParams.Network.ConnectionType = NetworkConnectionType.Kcp;
            connParams.Network.Kcp            = new KcpNetworkParameters
            {
                // These are the last tested values
                Heartbeat = new HeartbeatParameters
                {
                    IntervalMillis = 5000,
                    TimeoutMillis  = 10000
                }
            };

            var initializer = new MobileConnectionFlowInitializer(
                new MobileConnectionFlowInitializer.CommandLineSettingsProvider(),
                new MobileConnectionFlowInitializer.PlayerPrefsSettingsProvider(),
                this);

            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(connParams);

            if (UseSessionFlow)
            {
                builder.SetConnectionFlow(new ChosenDeploymentLocatorFlow(deployment,
                                                                          new SessionConnectionFlowInitializer(initializer)));
                return(builder);
            }

            switch (initializer.GetConnectionService())
            {
            case ConnectionService.Receptionist:
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.MobileClient),
                                                               initializer));
                break;

            case ConnectionService.Locator:
                builder.SetConnectionFlow(new LocatorFlow(initializer));
                break;

            default:
                throw new ArgumentException("Received unsupported connection service.");
            }

            return(builder);
        }
示例#6
0
        protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
        {
            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(CreateConnectionParameters(WorkerUtils.UnityGameLogic));

            if (Application.isEditor)
            {
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityGameLogic)));
            }
            else
            {
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityGameLogic),
                                                               new CommandLineConnectionFlowInitializer()));
            }

            return(builder);
        }
        protected override IConnectionHandlerBuilder GetConnectionHandlerBuilder()
        {
            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(CreateConnectionParameters(WorkerUtils.SimulatedPlayerCoordinator));

            var workerId = CreateNewWorkerId(WorkerUtils.SimulatedPlayerCoordinator);

            if (Application.isEditor)
            {
                builder.SetConnectionFlow(new ReceptionistFlow(workerId));
            }
            else
            {
                builder.SetConnectionFlow(new ReceptionistFlow(workerId, new CommandLineConnectionFlowInitializer()));
            }

            return(builder);
        }
示例#8
0
        private async void Start()
        {
            Application.targetFrameRate = 60;

            var connParams = CreateConnectionParameters(WorkerUtils.UnityClient);

            connParams.Network.UseExternalIp = UseExternalIp;

            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(connParams);

            if (!Application.isEditor)
            {
                var initializer = new CommandLineConnectionFlowInitializer();
                switch (initializer.GetConnectionService())
                {
                case ConnectionService.Receptionist:
                    builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient), initializer));
                    break;

                case ConnectionService.Locator:
                    builder.SetConnectionFlow(new LocatorFlow(initializer));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else
            {
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient)));
            }

            await Connect(builder, new ForwardingDispatcher());

            if (level == null)
            {
                return;
            }

            levelInstance = Instantiate(level, transform.position, transform.rotation);
        }
        private async void Start()
        {
            Application.targetFrameRate = 60;

            var connParams = CreateConnectionParameters(WorkerUtils.UnityClient);

            connParams.Network.UseExternalIp  = UseExternalIp;
            connParams.Network.ConnectionType = NetworkConnectionType.RakNet;

            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(connParams);

            if (!Application.isEditor)
            {
                var initializer = new CommandLineConnectionFlowInitializer();
                switch (initializer.GetConnectionService())
                {
                case ConnectionService.Receptionist:
                    builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient), initializer));
                    break;

                case ConnectionService.Locator:
                    builder.SetConnectionFlow(new LocatorFlow(initializer));
                    break;

                case ConnectionService.AlphaLocator:
                    builder.SetConnectionFlow(new AlphaLocatorFlow(initializer));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else
            {
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient)));
            }

            await Connect(builder, new ForwardingDispatcher()).ConfigureAwait(false);
        }
        public async void Start()
        {
            var connParams = CreateConnectionParameters(WorkerUtils.MobileClient, new MobileConnectionParametersInitializer());

            var flowInitializer = new MobileConnectionFlowInitializer(
                new MobileConnectionFlowInitializer.CommandLineSettingsProvider(),
                new MobileConnectionFlowInitializer.PlayerPrefsSettingsProvider(),
                this);

            var builder = new SpatialOSConnectionHandlerBuilder()
                          .SetConnectionParameters(connParams);

            switch (flowInitializer.GetConnectionService())
            {
            case ConnectionService.Receptionist:
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.MobileClient),
                                                               flowInitializer));
                break;

            case ConnectionService.Locator:
                builder.SetConnectionFlow(new LocatorFlow(flowInitializer));
                break;

            default:
                throw new ArgumentException("Received unsupported connection service.");
            }

            await Connect(builder, new ForwardingDispatcher());

            if (level == null)
            {
                return;
            }

            levelInstance = Instantiate(level, transform.position, transform.rotation);
        }