private static async Task MainImpl()
        {
            Console.WriteLine("creating account config.");

            var stormancerConfig = ClientConfiguration.ForAccount(_accountId, _appName);
            stormancerConfig.AddPlugin(new AuthenticationPlugin());

            Console.WriteLine("creating client.");

            var client = new Client(stormancerConfig);

            Console.WriteLine("Getting authenticator.");

            var authenticator = client.Authenticator();

            Console.WriteLine("Authenticating.");

            var mainScene = await authenticator.SteamLogin("myTicket");
            
            Console.WriteLine("Connecting to the authenticated scene.");

            await mainScene.Connect();

            Console.WriteLine("Connected.");
        }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        UniRx.MainThreadDispatcher.Initialize();
        var loadingCanvas = GameObject.Find("LoadingCanvas");
        var config = Stormancer.ClientConfiguration.ForAccount("d9590543-56c3-c94a-f7bf-c394b26deb15", "boids-test");
        config.Logger = DebugLogger.Instance;
        this._client = new Stormancer.Client(config);


        Debug.Log("calling GetPublicScene");
        _client.Authenticator().LoginAsViewer().ContinueWith(
            task =>
            {
                if (!task.IsFaulted)
                {
                    Debug.Log("test1");
                    var MatchMakerScene = task.Result;
                    var matchmaker = new MatchmakerClient(MatchMakerScene);
                    matchmaker.Connect().Then(s =>
                    {
                        matchmaker.FindMatch().Then(result =>
                        {
                            _client.GetScene(result.Token).Then(scene =>
                            {
                                _scene = scene;
                                scene.AddRoute("position.update", OnPositionUpdate);
                                scene.AddRoute<ushort>("ship.remove", OnShipRemoved);
                                scene.AddRoute("ship.usedSkill", OnUsedSkill);
                                scene.AddRoute<StatusChangedMsg>("ship.statusChanged", OnStatusChanged);
                                scene.AddRoute<ShipCreatedDto[]>("ship.add", OnShipAdded);
                                scene.AddRoute("ship.pv", OnShipPv);

                                _scene.Connect().Then(() =>
                                {
                                    Debug.Log("Call dispatcher to hide UI.");
                                    MainThread.Post(() =>
                                    {
                                        Debug.Log("Hiding UI.");
                                        loadingCanvas.SetActive(false);//Hide loading ui.


                                    });

                                })
                                .ContinueWith(t =>
                                {
                                    if (t.IsFaulted)
                                    {
                                        Debug.LogException(t.Exception.InnerException);
                                    }
                                });
                            });
                        });
                    });
                }
                else
                // task.IsFaulted
                {
                    Debug.Log("task faulted");
                }
            });
    }