aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-20 00:46:29 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-07-20 00:46:29 -0400
commitce20066bc0e2c7ba1634200cdee6ac339d4dfb60 (patch)
tree3a9a9f84031bf07d67eefb1a52251d701b279b0c /MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs
parent880fa216744340db2843c4f773664426ff8bfe36 (diff)
update translations
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs21
1 files changed, 19 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs
index f89cdac47..c7669fecb 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.Events;
+using System.Text;
+using MediaBrowser.Common.Events;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System;
@@ -36,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <param name="socket">The socket.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">socket</exception>
- public NativeWebSocket(System.Net.WebSockets.WebSocket socket, ILogger logger)
+ public NativeWebSocket(WebSocket socket, ILogger logger)
{
if (socket == null)
{
@@ -155,6 +156,22 @@ namespace MediaBrowser.Server.Implementations.HttpServer
return WebSocket.SendAsync(new ArraySegment<byte>(bytes), nativeType, true, linkedTokenSource.Token);
}
+ public Task SendAsync(byte[] bytes, bool endOfMessage, CancellationToken cancellationToken)
+ {
+ var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _cancellationTokenSource.Token);
+
+ return WebSocket.SendAsync(new ArraySegment<byte>(bytes), System.Net.WebSockets.WebSocketMessageType.Binary, true, linkedTokenSource.Token);
+ }
+
+ public Task SendAsync(string text, bool endOfMessage, CancellationToken cancellationToken)
+ {
+ var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _cancellationTokenSource.Token);
+
+ var bytes = Encoding.UTF8.GetBytes(text);
+
+ return WebSocket.SendAsync(new ArraySegment<byte>(bytes), System.Net.WebSockets.WebSocketMessageType.Text, true, linkedTokenSource.Token);
+ }
+
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>