Exemplo n.º 1
0
 // ReSharper disable once UnusedMethodReturnValue.Local
 private bool TryGetDocument(HttpContext http, [NotNullWhen(true)] out Document?document)
 {
     document = default;
     return(MiddlewareCommon.TryGetParameter(http.Request.Query, "doc", out var text) &&
            Guid.TryParseExact(text, GlobalConstants.GuidFormat, out var documentId) &&
            MiddlewareCommon.TryFindConnection(_app, http, out var connection) &&
            connection.TryGetDocument(documentId, out document));
 }
Exemplo n.º 2
0
        public bool TryGetSession([NotNullWhen(true)] out Session?session)
        {
            if (MiddlewareCommon.TryFindConnection(Application, Http, out var connection))
            {
                session = connection.Session;
                return(true);
            }

            session = default;
            return(false);
        }
Exemplo n.º 3
0
        internal static Connection GetConnection(Application app, HttpContext http)
        {
            Connection connection = null;

            MiddlewareCommon.TryFindConnection(app, http, out connection);

            if (connection == null)
            {
                connection = CreateConnection(app, http);
            }

            return(connection);
        }
Exemplo n.º 4
0
 private static async Task ProcessRequest(PostEventContext context)
 {
     if (MiddlewareCommon.TryFindConnection(context.Application, context.Http, out var connection) &&
         context.Parameters != null &&
         connection.TryGetDocument(context.Parameters.DocumentId, out var document))
     {
         context.Connection = connection;
         context.Document   = document;
         await ProcessRequestDocument(context);
     }
     else
     {
         await SendEvent(context, EventResultType.NoSession);
     }
 }
Exemplo n.º 5
0
        internal override async Task <bool> ProcessRequest(HttpContext http)
        {
            if (http.Request.Method != "POST" || http.Request.Path != "/_discard" ||
                !DiscardParameters.TryParse(http, out var parameters) ||
                !MiddlewareCommon.TryFindConnection(_app, http, out var connection))
            {
                return(false);
            }
            await Task.Delay(DiscardDelay);

            await connection.Discard(parameters.DocumentId);

            await _app.ClearEmptyConnection(connection);

            return(true);
        }
Exemplo n.º 6
0
 internal static Connection GetConnection(Application app, HttpContext http)
 {
     return(MiddlewareCommon.TryFindConnection(app, http, out var connection) ? connection : CreateConnection(app, http));
 }