Exemple #1
0
        private void OnServerStatusResponse(ServerStatusResponse response)
        {
            var error       = response.Connected == "error";
            var isConnected = response.Connected == "true";

            if (error)
            {
                OnDisconnected(new InvalidOperationException(response.Text));
                return;
            }

            if (isConnected)
            {
                SendOutMessage(new Messages.ConnectMessage());
            }
            else
            {
                OnDisconnected(null);
            }
        }
Exemple #2
0
        public override void Enter()
        {
            this.Session.AppendResponse(new ExistResponse(_mailbox.Exist));
            this.Session.AppendResponse(new RecentResponse(_mailbox.Recent));
            ServerStatusResponse rep = new ServerStatusResponse(
                "*",
                ServerStatusResponseType.OK,
                "UIDs valid",
                new ResponseCode(ResponseCodeType.UIDVALIDITY, this._mailbox.UidValidity.ToString())
                );

            this.Session.AppendResponse(rep);
            this.Session.AppendResponse(new FlagResponse());
            rep = new ServerStatusResponse(
                "*",
                ServerStatusResponseType.OK,
                "Limited",
                new ResponseCode(ResponseCodeType.PERMANENTFLAGS, "(\\Answered \\Seen \\Deleted \\Draft \\Flagged)"));
            this.Session.AppendResponse(rep);
        }
Exemple #3
0
        public async Task <ActionResult> GetIndex()
        {
            var totalAcc    = 0d;
            var divideTotal = 0d;
            var i           = 0;

            _context
            .Scores
            .Take(500)
            .OrderByDescending(s => s.PerformancePoints)
            .ForEach(
                s =>
            {
                var divide = Math.Pow(.95d, i);

                totalAcc    += s.Accuracy * divide;
                divideTotal += divide;

                i++;
            }
                );

            var totalAccuracy  = divideTotal > 0 ? totalAcc / divideTotal : 0;
            var statusResponse = new ServerStatusResponse
            {
                ConnectedUsers         = _ps.ConnectedPresences - 1, // Sora doesn't count as user!
                RegisteredUsers        = await _context.Users.CountAsync() - 1,
                BannedUsers            = await _context.Users.Where(u => u.Status == UserStatusFlags.Restricted).CountAsync(),
                SubmittedScores        = await _context.Scores.CountAsync(),
                TotalPerformancePoints = await _context.Leaderboard.SumAsync(x => x.PerformancePointsOsu +
                                                                             x.PerformancePointsTaiko +
                                                                             x.PerformancePointsCtb +
                                                                             x.PerformancePointsMania),
                AverageAccuracy = totalAccuracy
            };

            return(Ok(JsonConvert.SerializeObject(statusResponse)));
        }