Exemplo n.º 1
0
        private async Task <IActionResult> DoHeartbeat(HeartbeatArgs args)
        {
            var heart = args.Heart ?? "General";

            var t = await Db.GetTopic(args.Topic);

            if (t == null)
            {
                return(new NotFoundResult());
            }
            else if (!t.WriteToken.Equals(args.WriteToken, StringComparison.Ordinal))
            {
                return(StatusCode(403));
            }

            if (Timeouts.IsTimedOut(t.TopicId))
            {
                return(StatusCode(StatusCodes.Status429TooManyRequests));
            }

            var affected = await Db.ReportHeartbeat(t.TopicId, heart, args.ExpiryTimeout);

            if (affected == 1)
            {
                await Herald.HeartbeatSent(t, heart);
            }

            Timeouts.ApplyCost(t.TopicId, Config.HeartbeatCost);

            return(new OkResult());
        }
Exemplo n.º 2
0
        private static void Server_HeartbeatEvent(object sender, HeartbeatArgs e)
        {
            // Check if there is a pending Client Retry
            Retry retry = retryList.FirstOrDefault(xx => xx.ipAddress == e.clientIp);

            // If there is a pending Client Retry
            if (retry != null)
            {
                // Create RecordingsJson Object
                RecordingsJson recordingsJson = new RecordingsJson {
                    recordingEntries = retry.recordingEntries
                };
                // Remove Old Retry
                retryList.Remove(retry);
                // Retry ResumeUpdate
                RetryResumeUpdate(JsonConvert.SerializeObject(recordingsJson), retry.ipAddress);
            }
        }
Exemplo n.º 3
0
 public Task <IActionResult> HeartbeatGet([FromQuery] HeartbeatArgs args) => DoHeartbeat(args);