aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Net/HttpServer.cs
diff options
context:
space:
mode:
authorLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-07-19 22:22:44 -0400
committerLukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com>2012-07-19 22:22:44 -0400
commit80b3ad7bd20329e6a5bbf6eeb76af62c87434a7c (patch)
tree81ab455261cf30fab4b932215211d8cd0e57547a /MediaBrowser.Common/Net/HttpServer.cs
parent6fbd5cf46407a212fadb52eee00c7ac7690430ea (diff)
Moved the http server to it's own assembly. added comments and made other minor re-organizations.
Diffstat (limited to 'MediaBrowser.Common/Net/HttpServer.cs')
-rw-r--r--MediaBrowser.Common/Net/HttpServer.cs42
1 files changed, 0 insertions, 42 deletions
diff --git a/MediaBrowser.Common/Net/HttpServer.cs b/MediaBrowser.Common/Net/HttpServer.cs
deleted file mode 100644
index fad8d13eb..000000000
--- a/MediaBrowser.Common/Net/HttpServer.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Net;
-using System.Reactive.Linq;
-
-namespace MediaBrowser.Common.Net
-{
- public class HttpServer : IObservable<RequestContext>, IDisposable
- {
- private readonly HttpListener listener;
- private readonly IObservable<RequestContext> stream;
-
- public HttpServer(string url)
- {
- listener = new HttpListener();
- listener.Prefixes.Add(url);
- listener.Start();
- stream = ObservableHttpContext();
- }
-
- private IObservable<RequestContext> ObservableHttpContext()
- {
- return Observable.Create<RequestContext>(obs =>
- Observable.FromAsyncPattern<HttpListenerContext>(listener.BeginGetContext,
- listener.EndGetContext)()
- .Select(c => new RequestContext(c))
- .Subscribe(obs))
- .Repeat()
- .Retry()
- .Publish()
- .RefCount();
- }
- public void Dispose()
- {
- listener.Stop();
- }
-
- public IDisposable Subscribe(IObserver<RequestContext> observer)
- {
- return stream.Subscribe(observer);
- }
- }
-} \ No newline at end of file