Exemple #1
0
 //public bool ResetPlayer()
 //{
 //    if (HubConnection != null && User != null)
 //    {
 //        Player = new LocalPlayer(HubConnection);
 //        return true;
 //    }
 //    return false;
 //}
 public GwentClientService(HubConnection hubConnection)
 {
     /*待修改*/
     (sender, receiver) = Tube.CreateSimplex();
     /*待修改*/
     hubConnection.On <bool>("MatchResult", async x =>
     {
         await sender.SendAsync <bool>(x);
     });
     hubConnection.On("RepeatLogin", async() =>
     {
         SceneManager.LoadScene("LoginSecen");
         await DependencyResolver.Container.Resolve <GlobalUIService>().YNMessageBox("账号被其他人强制登陆", "账号被登陆,被挤下了线");
     });
     hubConnection.Closed += (async x =>
     {
         Debug.Log("断线!");
         //var user = DependencyResolver.Container.Resolve<GwentClientService>().User;
         //await Task.Delay(100);
         //await DependencyResolver.Container.Resolve<HubConnection>().StartAsync();
         //var result = await DependencyResolver.Container.Resolve<HubConnection>().InvokeAsync<bool>("Reconnect", user.UserName, user.PassWord);
         //if (result) Debug.Log("尝试重连成功");
         //else
         //{
         SceneManager.LoadScene("LoginSecen");
         Debug.Log("跳转!");
         await DependencyResolver.Container.Resolve <GlobalUIService>().YNMessageBox("断开连接", "请尝试重新登陆");
         //}
     });
     //////////////////////////////
     hubConnection.On <string>("Test", message => Debug.Log($"收到了服务端来自Debug的信息:{message}"));
     Player        = new LocalPlayer(hubConnection);
     HubConnection = hubConnection;
     hubConnection.StartAsync();
 }
Exemple #2
0
        public GwentClientService(HubConnection hubConnection, GlobalUIService globalUIService, ITranslator translator)
        {
            _translator      = translator;
            _globalUIService = globalUIService;
            /*待修改*/
            (sender, receiver) = Tube.CreateSimplex();
            /*待修改*/
            hubConnection.On <bool>("MatchResult", async x =>
            {
                await sender.SendAsync <bool>(x);
            });
            hubConnection.On("RepeatLogin", async() =>
            {
                SceneManager.LoadScene("LoginScene");
                await DependencyResolver.Container.Resolve <GlobalUIService>().YNMessageBox(_translator.GetText("logged_out_title"), _translator.GetText("logged_out"));
            });
            hubConnection.Closed += (async x =>
            {
                SceneManager.LoadScene("LoginScene");
                await _globalUIService.YNMessageBox(_translator.GetText("disconnected_title"),
                                                    _translator.GetText("disconnected").Replace("\\n", "\n"),
                                                    "ok_button", isOnlyYes: true);

                // LayoutRebuilder.ForceRebuildLayoutImmediate(Context);
                // var messageBox = GameObject.Find("GlobalUI").transform.Find("MessageBoxBg").gameObject.GetComponent<MessageBox>();//.Show("断开连接", "请尝试重新登陆\n注意! 在目前版本中,如果处于对局或匹配时断线,需要重新启动客户端,否则下次游戏开始时会异常卡死。\nNote!\nIn the current version, if you are disconnected when matching or Playing, you need to restart the client, otherwise the next game will start with an abnormal.".Replace("\\n", "\n"), isOnlyYes: true);
                // messageBox.Buttons.SetActive(true);
                // messageBox.YesButton.SetActive(true);
                // messageBox.NoButton.SetActive(false);
                // messageBox.TitleText.text = "断开连接";
                // messageBox.MessageText.text = "请尝试重新登陆\n注意! 在目前版本中,如果处于对局或匹配时断线,需要重新启动客户端,否则下次游戏开始时会异常卡死。\nNote!\nIn the current version, if you are disconnected when matching or Playing, you need to restart the client, otherwise the next game will start with an abnormal.".Replace("\\n", "\n");
                // messageBox.YesText.text = "确定";
                // messageBox.gameObject.SetActive(true);
                // await messageBox.receiver.ReceiveAsync<bool>();
                // LayoutRebuilder.ForceRebuildLayoutImmediate(messageBox.Context);
            });
            hubConnection.On("ExitGame", () =>
            {
                Application.Quit();
            });
            hubConnection.On <string, string, string, string, bool>("ShowMessageBox", (string title, string message, string yes, string no, bool isyes) =>
            {
                _globalUIService.YNMessageBox(title, message, yes, no, isyes);
            });
            hubConnection.On <string, string>("Wait", (string title, string message) =>
            {
                _globalUIService.Wait(title, message);
            });
            hubConnection.On("Close", () =>
            {
                _globalUIService.Close();
            });
            hubConnection.On <string>("Test", message => Debug.Log($"收到了服务端来自Debug的信息:{message}"));
            Player        = new LocalPlayer(hubConnection);
            HubConnection = hubConnection;
            hubConnection.StartAsync();
        }
Exemple #3
0
 public GwentClientService(HubConnection hubConnection)
 {
     /*待修改*/
     (sender, receiver) = Tube.CreateSimplex();
     /*待修改*/
     hubConnection.On <bool>("MatchResult", async x =>
     {
         await sender.SendAsync <bool>(x);
     });
     hubConnection.On("RepeatLogin", async() =>
     {
         SceneManager.LoadScene("LoginSecen");
         await DependencyResolver.Container.Resolve <GlobalUIService>().YNMessageBox("账号被其他人强制登陆", "账号被登陆,被挤下了线");
     });
     hubConnection.Closed += (async x =>
     {
         SceneManager.LoadScene("LoginSecen");
         await DependencyResolver.Container.Resolve <GlobalUIService>().YNMessageBox("断开连接", "请尝试重新登陆");
     });
     hubConnection.On <string>("Test", message => Debug.Log($"收到了服务端来自Debug的信息:{message}"));
     Player        = new LocalPlayer(hubConnection);
     HubConnection = hubConnection;
     hubConnection.StartAsync();
 }
Exemple #4
0
 private void Awake() => (sender, receiver) = Tube.CreateSimplex();