Пример #1
0
        private async Task InitializeClient()
        {
             this.Client = new MeteorClient(new Uri("ws://localhost:3000/websocket"));
            await this.Client.ConnectAsync();

            var manager = new LoginManager();
            var sessionToken = manager.GetSavedSessionToken();
            if (!string.IsNullOrWhiteSpace(sessionToken))
            {
                try
                {
                    await this.Client.LoginResumeSession(sessionToken);
                }
                catch (DdpServerException)
                {
                   
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes the ViewModel from  Meteor
        /// </summary>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        private async Task Initialize()
        {
            this.client = new MeteorClient(new Uri("ws://localhost:3000/websocket"));
            await this.client.ConnectAsync();

            this.players = this.client.GetCollection<Player>("players");
            DdpFilteredCollection<Player> sortedPlayers = this.players.Filter(
                sortFilter: (p1, p2) =>
                    {
                        var scoreComparison = p2.Score.CompareTo(p1.Score);

                        if (scoreComparison != 0)
                        {
                            return scoreComparison;
                        }

                        return string.Compare(p1.Name, p2.Name, System.StringComparison.Ordinal);
                    });

            this.viewModel = new LeaderboardViewModel(sortedPlayers);

            this.DataContext = this.viewModel;
        }