示例#1
0
        protected override void ObtainData(object sender, DoWorkEventArgs e)
        {
            Success = null;
            if (!m_Identified)
            {
                LoadingDataVm.SmallLoadingMessage = "Reaching the server ...";
                Thread.Sleep(1000);
                if (!m_Server.Connect())
                {
                    Success = false;
                    MessageBox.Show("Unreachable");
                    return;
                }

                m_Server.ServerLost += m_Server_ServerLost;
                m_Server.Start();

                LoadingDataVm.SmallLoadingMessage = "Checking Compatibility ...";
                Thread.Sleep(1000);
                var compat = m_Server.CheckServerCompatibility(typeof(App).Assembly.FullName);
                if (!compat.Success)
                {
                    Success = false;
                    MessageBox.Show($"{compat.MessageId}: {compat.Message}{Environment.NewLine}Server: {compat.ServerIdentification}{Environment.NewLine}Server protocol: {compat.ImplementedProtocolVersion}", "Server and client are not compatible");
                    return;
                }
                m_Game = compat.AvailableGames.FirstOrDefault();

                LoadingDataVm.SmallLoadingMessage = "Identifying the Player ...";
                Thread.Sleep(1000);
                if (!m_Server.Identify(m_Name))
                {
                    Success = false;
                    MessageBox.Show("Can't identify as " + m_Name);
                    return;
                }
                m_Identified = true;
            }

            LoadingDataVm.SmallLoadingMessage = "Getting List of tables ...";
            Thread.Sleep(1000);
            var tables = m_Server.ListTables(LobbyTypeEnum.QuickMode);

            if (tables == null)
            {
                Success = false;
                MessageBox.Show("Can't list tables!");
                return;
            }
            Tables.Clear();
            Tables.AddItems(tables);

            Success = true;
        }
 private void RefreshTablesCollection()
 {
     Tables.Clear();
     Tables.AddItems(_unitOfWork.Tables.GetAll());
     _availabilityChecker.ResetValues();
 }