source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Microsoft.Samples.Kinect.Webserver/IHttpRequestHandler.cs@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 3.3 KB
Line 
1// -----------------------------------------------------------------------
2// <copyright file="IHttpRequestHandler.cs" company="Microsoft">
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// </copyright>
5// -----------------------------------------------------------------------
6
7namespace Microsoft.Samples.Kinect.Webserver
8{
9 using System.Net;
10 using System.Threading.Tasks;
11
12 /// <summary>
13 /// Interface called upon to handle HTTP requests.
14 /// </summary>
15 /// <remarks>
16 /// <para>
17 /// Objects that implement this interface are not expected to be thread-safe but are expected
18 /// to support async operations, so instances should be created and instance methods should
19 /// always be called from a single thread that is associated with a SynchronizationContext
20 /// that provides single-threaded message dispatch
21 /// (e.g.: System.Windows.Threading.DispatcherSynchronizationContext).
22 /// </para>
23 /// <para>
24 /// This means that IHttpRequestHandlers still have to be aware of potential reentrancy
25 /// resulting from asynchronous operations, but they don't have to protect data access with
26 /// locks.
27 /// </para>
28 /// </remarks>
29 public interface IHttpRequestHandler
30 {
31 /// <summary>
32 /// Prepares handler to start receiving HTTP requests.
33 /// </summary>
34 /// <returns>
35 /// Await-able task.
36 /// </returns>
37 /// <remarks>
38 /// Return value should never be null. Implementations should use Task.FromResult(0)
39 /// if function is implemented synchronously so that callers can await without
40 /// needing to check for null.
41 /// </remarks>
42 Task InitializeAsync();
43
44 /// <summary>
45 /// Handle an http request.
46 /// </summary>
47 /// <param name="requestContext">
48 /// Context containing HTTP request data, which will also contain associated
49 /// response upon return.
50 /// </param>
51 /// <param name="subpath">
52 /// Request URI path relative to the URI prefix associated with this request
53 /// handler in the HttpListener.
54 /// </param>
55 /// <returns>
56 /// Await-able task.
57 /// </returns>
58 /// <remarks>
59 /// Return value should never be null. Implementations should use Task.FromResult(0)
60 /// if function is implemented synchronously so that callers can await without
61 /// needing to check for null.
62 /// </remarks>
63 Task HandleRequestAsync(HttpListenerContext requestContext, string subpath);
64
65 /// <summary>
66 /// Cancel all pending operations.
67 /// </summary>
68 void Cancel();
69
70 /// <summary>
71 /// Lets handler know that no more HTTP requests will be received, so that it can
72 /// clean up resources associated with request handling.
73 /// </summary>
74 /// <returns>
75 /// Await-able task.
76 /// </returns>
77 /// <remarks>
78 /// Return value should never be null. Implementations should use Task.FromResult(0)
79 /// if function is implemented synchronously so that callers can await without
80 /// needing to check for null.
81 /// </remarks>
82 Task UninitializeAsync();
83 }
84}
Note: See TracBrowser for help on using the repository browser.