public void NotifyServer(SrServerNotification packet)
        {
            // TODO: allow this method only from localhost


            lock (syncRoot)
            {
                if (connectTask != null)
                {
                    this.logger.Warning("Not connected to {Hub}...", hubUrl);
                    return;
                }
            }

            try
            {
                this.logger.Information("Submission {Submission}: Reporting submission status using packet {@Packet}...", packet.SubmissionId, packet);

                // This will be executed async
                this.hubProxy.Invoke("ReportSubmissionStatus", packet);
            }
            catch (Exception ex)
            {
                // TODO
                this.logger.Error("Exception during hub method {HubMethod}", nameof(this.NotifyServer), ex);
            }
        }
Beispiel #2
0
        public void ReportSubmissionStatus(SrServerNotification packet)
        {
            var rid = (string)this.Context.Request.Environment["server.RemoteIpAddress"];

            if (rid != "127.0.0.1" && rid != "localhost" && rid != "::1")
            {
                throw new HubException($"Forbidden for {rid}!");
            }

            if (packet.Type == SrServerNotificationType.FinishedProcessing)
            {
                using (AsyncScopedLifestyle.BeginScope(this.container))
                {
                    ISubmissionsDataService sds = this.container.GetInstance <ISubmissionsDataService>();
                    var tmp = sds.GetById(packet.SubmissionId);

                    this.Clients.User(tmp.Participant.User.UserName).refreshGrid(0, tmp.ProblemId, tmp.Id);
                }
            }
        }