예제 #1
0
        public void ConnectScene()
        {
            Scene = ClientProvider.GetPublicScene(SceneId, "");
            if (Scene != null)
            {
                foreach (RemoteLogicBase logic in LocalLogics)
                {
                    logic.Init(Scene);
                }

                Scene.Connect().ContinueWith(t =>
                {
                    if (Scene.Connected == true)
                    {
                        Debug.Log("connected to scene: " + SceneId);
                        Connected = true;
                        foreach (RemoteLogicBase remotelogic in LocalLogics)
                        {
                            remotelogic.OnConnected();
                        }
                    }
                    else
                    {
                        Debug.LogWarning("failed to connect to scene: " + SceneId);
                    }
                });
            }
        }
 public StormancerSceneViewModel(Scene scn)
 {
     scene = scn;
     foreach(Route r in scn.RemoteRoutes)
     {
         this.remotes.TryAdd(r.Name, new StormancerRouteViewModel(r));
     }
 }
        private static async Task connect()
        {
            var config = ClientConfiguration.ForAccount("7794da14-4d7d-b5b5-a717-47df09ca8492", "testlatencerpc");
            config.ServerEndpoint = "http://api.stormancer.com";
            _client = new Client(config);

            _scene = await _client.GetPublicScene("test", "");
            await _scene.Connect();
        }
예제 #4
0
 public override void Init(Scene s)
 {
     s.AddRoute("chat", OnChat);
     s.AddRoute("UpdateInfo", OnUpdateInfo);
     s.AddRoute("DiscardInfo", OnDiscardInfo);
     SendBtn.onClick.AddListener(OnSendMessage);
     chatSlider.onValueChanged.AddListener(ShowMessages);
     Infos = new ChatUserInfo();
     Infos.User = UserInfo;
 }
예제 #5
0
 private void onGettingPublicScene(Task<Stormancer.Scene> task)
 {
     if (task.IsFaulted)
     {
         m_connecting = false;
         return;
     }
     Debug.Log("Scene get...");
     m_scene = task.Result;
     m_scene.AddRoute("UpdateGame", onUpdateGame);
     m_scene.AddRoute("JoinStartedGame", onJoinStartedGame);
     m_scene.AddRoute("GetIdPlayer", onGetIdPlayer);
     m_scene.Connect().ContinueWith(onSceneConnecting);
 }
 public override void Init(Scene s)
 {
     if (s != null)
     {
         Debug.Log("replicator initializing");
         Clock = s.DependencyResolver.GetComponent<IClock>();
         s.AddProcedure("RequestObjects", OnRequestObjects);
         s.AddRoute("PlayerDisconnected", OnPlayerDisconnect);
         s.AddRoute("CreateObject", OnCreateObject);
         s.AddRoute("DestroyObject", OnDestroyObject);
         s.AddRoute("ForceUpdate", OnForceUpdate);
         s.AddRoute("UpdateObject", OnUpdateObject);
     }
 }
        // Use this for initialization
        public Task<Scene> Connect()
        {
            ClientConfiguration config;
            config = ClientConfiguration.ForAccount(AccountId, Application);

            config.Logger = DebugLogger.Instance;

            _client = new Stormancer.Client(config);
            _client.GetPublicScene(this.SceneId, "")
                .ContinueWith<Scene>(task =>
                {
                    if (task.IsFaulted)
                    {
                        Debug.LogException(task.Exception);
                    }
                    return task.Result;
                }).Then(scene =>
            {
                lock (this._configLock)
                {
                    this._scene = scene;
                    if (this._initConfig != null)
                    {
                        this._initConfig(this._scene);
                    }
                }
                return scene.Connect();
            })
                    .ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    this._connectedTcs.SetException(t.Exception);
                }
                else
                {
                    Debug.Log("Stormancer scene connected");
                    this._connectedTcs.SetResult(_scene);
                }
            });

            return this.ConnectedTask;
        }
        public async Task<AuthenticationResult> Authenticate(Client client)
        {
            _scene = await client.GetPublicScene("authenticator", true);
            var login = UserGenerator.Instance.GetLoginPassword();
            await _scene.Connect();
            Result = await Login(login.Item1, login.Item2);
            if (!Result.Success)
            {
                Console.WriteLine(Result.ErrorMsg);

                Result = await CreateAccount(login.Item1, login.Item2);
                if(Result.Success)
                {
                    Result = await Login(login.Item1, login.Item2);

                }
            }
            //client.Disconnect();
            return Result;
        }
예제 #9
0
 void Start()
 {
     m_connected = false;
     m_connecting = false;
     ClientConfiguration config = ClientConfiguration.ForAccount("5c8354d8-9fd0-5c5f-4c00-3eff266d1836", "rtype");
     client = new Client(config);
     m_scene = null;
     actualGame = null;
 }
예제 #10
0
 public MatchmakerClient(Scene matchmakerScene)
 {
     _scene = matchmakerScene;
 }
예제 #11
0
        private async Task Initialize()
        {

            //var accountId = _accountId;
            //var applicationName = _app;
            //var sceneName = _sceneId;
            //var config = Stormancer.ClientConfiguration.ForAccount(accountId, applicationName);
            //config.AsynchrounousDispatch = false;
            //config.ServerEndpoint = _apiEndpoint;
            //config.Logger = new Logger();
            //_client = new Stormancer.Client(config);
            _simulation.Boid.Clock = () => _client.Clock;
            _simulation.Boid.Fire = async (target, w) => (await _scene.RpcTask<UserSkillRequest, UseSkillResponse>("skill", new UserSkillRequest { skillId = w.id, target = target.Id }));
            var scene = await _client.GetScene(_token);

            scene.AddRoute("position.update", OnPositionUpdate);
            scene.AddRoute("ship.remove", OnShipRemoved);
            scene.AddRoute("ship.add", OnShipAdded);
            scene.AddRoute("ship.me", OnGetMyShipInfos);
            scene.AddRoute("ship.statusChanged", OnShipStatusChanged);
            scene.AddRoute("ship.usedSkill", OnShipUsedSkill);
            scene.AddRoute("ship.forcePositionUpdate", OnForcePositionUpdate);
            scene.AddRoute("game.statusChanged", OnGameStatusChanged);
            await scene.Connect();

            _scene = scene;

            IsRunning = true;
        }
예제 #12
0
 public abstract void Init(Scene s);
        // Use this for initialization
        void Start()
        {
            ClientConfiguration config;
            if (this.UseLocalEmulator)
            {
                config = ClientConfiguration.ForLocalDev(this.Application);
            }else{
                config = ClientConfiguration.ForAccount(AccountId, Application);
            }

            if(Client == null)
            {
                Client = new Stormancer.Client(config);
            }
           
            Task<Scene> sceneTask;

            if(IsLobby)
            {
                sceneTask = Client.GetPublicScene(this.SceneId, new PlayerInfosDto{ Name = NetworkRefs.Username });
            }else{
                sceneTask = Client.GetScene(NetworkRefs.Token);
            }

            sceneTask.ContinueWith(
            task => {
                if (task.IsFaulted)
                {
                    NetworkRefs.logError = true;
                    Debug.LogException(task.Exception);
					QueueOnMainThread(
						() =>{
							UnityEngine.Application.LoadLevel("Login");
						});
                }
                return task.Result;
            }).Then(
            scene =>
            {                
                lock (this._configLock)
                {
                    this._scene = scene;
                    SceneId = scene.Id;
                    if (this._initConfig != null)
                    {
                        this._initConfig(this._scene);
                        this._initConfig = null;
                    }
                }
                return scene.Connect();
            }).ContinueWith(
            t => 
            {
                if (t.IsFaulted)
                {
                    this._connectedTcs.SetException(t.Exception);
                }else{
                    Debug.Log("Stormancer scene connected");
                    this._connectedTcs.SetResult(true);
                }
            });
        }
		public StormancerSceneViewModel(Scene scn)
		{
			scene = scn;
		}