aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Net
diff options
context:
space:
mode:
authorBond_009 <Bond.009@outlook.com>2019-12-17 23:15:02 +0100
committerBond_009 <bond.009@outlook.com>2020-01-13 20:06:08 +0100
commit976459d3e8a8b889cebc2cf281e38b0fbc19c9b9 (patch)
treea9604c194d3285b8e7b336a08939cefe713a16ce /MediaBrowser.Controller/Net
parentce7744806c62d54d88acd3e538091f7beaa5601f (diff)
Rewrite WebSocket handling code
Diffstat (limited to 'MediaBrowser.Controller/Net')
-rw-r--r--MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs1
-rw-r--r--MediaBrowser.Controller/Net/IHttpServer.cs22
-rw-r--r--MediaBrowser.Controller/Net/IWebSocketConnection.cs28
3 files changed, 6 insertions, 45 deletions
diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
index ee5c1a165..9d71426d8 100644
--- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
+++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs
@@ -154,7 +154,6 @@ namespace MediaBrowser.Controller.Net
{
MessageType = Name,
Data = data
-
}, cancellationToken).ConfigureAwait(false);
state.DateLastSendUtc = DateTime.UtcNow;
diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs
index 46933c046..694e3954e 100644
--- a/MediaBrowser.Controller/Net/IHttpServer.cs
+++ b/MediaBrowser.Controller/Net/IHttpServer.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Services;
@@ -20,11 +19,6 @@ namespace MediaBrowser.Controller.Net
string[] UrlPrefixes { get; }
/// <summary>
- /// Stops this instance.
- /// </summary>
- void Stop();
-
- /// <summary>
/// Occurs when [web socket connected].
/// </summary>
event EventHandler<GenericEventArgs<IWebSocketConnection>> WebSocketConnected;
@@ -40,22 +34,10 @@ namespace MediaBrowser.Controller.Net
string GlobalResponse { get; set; }
/// <summary>
- /// Sends the http context to the socket listener
- /// </summary>
- /// <param name="ctx"></param>
- /// <returns></returns>
- Task ProcessWebSocketRequest(HttpContext ctx);
-
- /// <summary>
/// The HTTP request handler
/// </summary>
- /// <param name="httpReq"></param>
- /// <param name="urlString"></param>
- /// <param name="host"></param>
- /// <param name="localPath"></param>
- /// <param name="cancellationToken"></param>
+ /// <param name="context"></param>
/// <returns></returns>
- Task RequestHandler(IHttpRequest httpReq, string urlString, string host, string localPath,
- CancellationToken cancellationToken);
+ Task RequestHandler(HttpContext context);
}
}
diff --git a/MediaBrowser.Controller/Net/IWebSocketConnection.cs b/MediaBrowser.Controller/Net/IWebSocketConnection.cs
index 566897b31..e2a714d5b 100644
--- a/MediaBrowser.Controller/Net/IWebSocketConnection.cs
+++ b/MediaBrowser.Controller/Net/IWebSocketConnection.cs
@@ -1,9 +1,9 @@
using System;
+using System.Net;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
-using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Controller.Net
@@ -16,12 +16,6 @@ namespace MediaBrowser.Controller.Net
event EventHandler<EventArgs> Closed;
/// <summary>
- /// Gets the id.
- /// </summary>
- /// <value>The id.</value>
- Guid Id { get; }
-
- /// <summary>
/// Gets the last activity date.
/// </summary>
/// <value>The last activity date.</value>
@@ -32,6 +26,7 @@ namespace MediaBrowser.Controller.Net
/// </summary>
/// <value>The URL.</value>
string Url { get; set; }
+
/// <summary>
/// Gets or sets the query string.
/// </summary>
@@ -54,7 +49,7 @@ namespace MediaBrowser.Controller.Net
/// Gets the remote end point.
/// </summary>
/// <value>The remote end point.</value>
- string RemoteEndPoint { get; }
+ IPAddress RemoteEndPoint { get; }
/// <summary>
/// Sends a message asynchronously.
@@ -66,21 +61,6 @@ namespace MediaBrowser.Controller.Net
/// <exception cref="ArgumentNullException">message</exception>
Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken);
- /// <summary>
- /// Sends a message asynchronously.
- /// </summary>
- /// <param name="buffer">The buffer.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task.</returns>
- Task SendAsync(byte[] buffer, CancellationToken cancellationToken);
-
- /// <summary>
- /// Sends a message asynchronously.
- /// </summary>
- /// <param name="text">The text.</param>
- /// <param name="cancellationToken">The cancellation token.</param>
- /// <returns>Task.</returns>
- /// <exception cref="ArgumentNullException">buffer</exception>
- Task SendAsync(string text, CancellationToken cancellationToken);
+ Task ProcessAsync(CancellationToken cancellationToken = default);
}
}