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); } }); } }
private void InitSceneAndConnect(Scene scene) { if (scene != null) { Scene = scene; foreach (RemoteLogicBase logic in LocalLogics) { logic.Init(Scene); } Scene.Connect().ContinueWith(t => { if (Scene.Connected) { Debug.Log("connected to scene: " + SceneId); Connected = true; foreach (RemoteLogicBase remotelogic in LocalLogics) { remotelogic.OnConnected(); } } else { Debug.LogWarning("failed to connect to scene: " + SceneId); } }); } }
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(); }
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); }
private void onSceneConnecting(Task<Scene> task) { if (task.IsFaulted) { Debug.Log("Can't get scene."); m_connecting = false; return; } m_scene = task.Result; m_scene.AddRoute("CreateEntity", onCreateEntity); m_scene.AddRoute("DestroyEntity", onDestroyEntity); m_scene.AddRoute("PosUpdatePlayer", onUpdatePos); m_scene.AddRoute("PlayerDisconnected", onPlayerDisconnected); m_scene.Connect().ContinueWith(onConnected); }
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; }
public Task Connect() { return(_scene.Connect()); }
// 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"); } }); }
void Connect() { if (_connected == false && _connecting == false) { Debug.Log ("start connection procedure"); ConnectionDtO cdto = new ConnectionDtO(connectionPanel.username.text, version); connectionPanel.error.text = "Connecting"; _connecting = true; _local_client.GetPublicScene ("main", cdto).ContinueWith (task => { if (task.IsFaulted) { Debug.Log ("connection failed : " + task.Exception.Message); _connecting = false; } else { _scene = task.Result; Debug.Log ("configuring routes"); _scene.AddRoute ("create_ball", onCreateBalls); _scene.AddRoute ("destroy_ball", onDestroyBalls); Debug.Log ("connecting to remote scene"); _scene.Connect().ContinueWith( t => { if (_scene.Connected) { _connected = true; _connecting = false; Debug.Log("connection succeful"); UniRx.MainThreadDispatcher.Post (() =>{ connectionPanel.error.text = "Please enter a username"; connectionPanel.connectBtn.enabled = true; }); } else { Debug.Log ("connection failed: " + t.Exception.InnerException.Message); _connecting = false; UniRx.MainThreadDispatcher.Post (() =>{ connectionPanel.error.text = t.Exception.InnerException.Message; }); } }); } }); } }