wasSharpNET – Diff between revs 16 and 19
?pathlinks?
Rev 16 | Rev 19 | |||
---|---|---|---|---|
Line 13... | Line 13... | |||
13 | { |
13 | { |
|
14 | public abstract class HTTPServer : IDisposable |
14 | public abstract class HTTPServer : IDisposable |
|
15 | { |
15 | { |
|
16 | private int activeRequests; |
16 | private int activeRequests; |
|
Line 17... | Line 17... | |||
17 | |
17 | |
|
18 | private HttpListener HTTPListener = new HttpListener() |
- | ||
19 | { |
- | ||
20 | AuthenticationSchemes = AuthenticationSchemes.None |
- | ||
Line 21... | Line 18... | |||
21 | }; |
18 | private HttpListener HTTPListener = null; |
|
Line 22... | Line 19... | |||
22 | |
19 | |
|
23 | private int processedRequests; |
- | ||
24 | |
- | ||
25 | public AuthenticationSchemes AuthenticationSchemes |
- | ||
26 | { |
- | ||
27 | get |
- | ||
28 | { |
- | ||
29 | return HTTPListener.AuthenticationSchemes; |
- | ||
30 | } |
20 | private int processedRequests; |
|
31 | set |
- | ||
32 | { |
- | ||
Line 33... | Line 21... | |||
33 | HTTPListener.AuthenticationSchemes = value; |
21 | |
|
Line 34... | Line 22... | |||
34 | } |
22 | public AuthenticationSchemes AuthenticationSchemes { get; set; } = |
|
35 | } |
23 | AuthenticationSchemes.None; |
|
36 | |
24 | |
|
- | 25 | public bool IsRunning => HTTPListener != null && HTTPListener.IsListening; |
||
37 | public bool IsRunning => HTTPListener.IsListening; |
26 | |
|
38 | |
27 | public bool Start(IEnumerable<string> prefixes) |
|
Line 39... | Line 28... | |||
39 | public bool Start(IEnumerable<string> prefixes) |
28 | { |
|
40 | { |
29 | HTTPListener = new HttpListener() |
|
41 | // Do not start the HTTP server if it is already running. |
30 | { |
|
42 | if (HTTPListener.IsListening) |
31 | AuthenticationSchemes = AuthenticationSchemes |
|
Line 54... | Line 43... | |||
54 | HTTPListener.Start(); |
43 | HTTPListener.Start(); |
|
55 | ThreadPool.QueueUserWorkItem(Listen, new HTTPServerCallbackState(HTTPListener)); |
44 | ThreadPool.QueueUserWorkItem(Listen, new HTTPServerCallbackState(HTTPListener)); |
|
56 | return true; |
45 | return true; |
|
57 | } |
46 | } |
|
Line 58... | Line 47... | |||
58 | |
47 | |
|
59 | public bool Stop() |
48 | public void Stop() |
|
60 | { |
49 | { |
|
61 | HTTPListener.Stop(); |
- | ||
62 | return true; |
50 | HTTPListener.Stop(); |
|
Line 63... | Line 51... | |||
63 | } |
51 | } |
|
64 | |
52 | |
|
65 | private void Listen(object state) |
53 | private void Listen(object state) |