mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-16 05:53:03 +03:00
Update to 3.5.2 and .net core 2.1
This commit is contained in:
@@ -118,6 +118,8 @@ namespace Emby.Server.Implementations.Net
|
||||
|
||||
public IAsyncResult BeginReceive(byte[] buffer, int offset, int count, AsyncCallback callback)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
EndPoint receivedFromEndPoint = new IPEndPoint(IPAddress.Any, 0);
|
||||
|
||||
return _Socket.BeginReceiveFrom(buffer, offset, count, SocketFlags.None, ref receivedFromEndPoint, callback, buffer);
|
||||
@@ -125,17 +127,21 @@ namespace Emby.Server.Implementations.Net
|
||||
|
||||
public int Receive(byte[] buffer, int offset, int count)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
return _Socket.Receive(buffer, 0, buffer.Length, SocketFlags.None);
|
||||
}
|
||||
|
||||
public SocketReceiveResult EndReceive(IAsyncResult result)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
|
||||
EndPoint remoteEndPoint = (EndPoint)sender;
|
||||
|
||||
var receivedBytes = _Socket.EndReceiveFrom(result, ref remoteEndPoint);
|
||||
|
||||
var buffer = (byte[]) result.AsyncState;
|
||||
var buffer = (byte[])result.AsyncState;
|
||||
|
||||
return new SocketReceiveResult
|
||||
{
|
||||
@@ -148,13 +154,20 @@ namespace Emby.Server.Implementations.Net
|
||||
|
||||
public Task<SocketReceiveResult> ReceiveAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
var taskCompletion = new TaskCompletionSource<SocketReceiveResult>();
|
||||
bool isResultSet = false;
|
||||
|
||||
Action<IAsyncResult> callback = callbackResult =>
|
||||
{
|
||||
try
|
||||
{
|
||||
taskCompletion.TrySetResult(EndReceive(callbackResult));
|
||||
if (!isResultSet)
|
||||
{
|
||||
isResultSet = true;
|
||||
taskCompletion.TrySetResult(EndReceive(callbackResult));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -167,6 +180,7 @@ namespace Emby.Server.Implementations.Net
|
||||
if (result.CompletedSynchronously)
|
||||
{
|
||||
callback(result);
|
||||
return taskCompletion.Task;
|
||||
}
|
||||
|
||||
cancellationToken.Register(() => taskCompletion.TrySetCanceled());
|
||||
@@ -176,6 +190,8 @@ namespace Emby.Server.Implementations.Net
|
||||
|
||||
public Task<SocketReceiveResult> ReceiveAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
var buffer = new byte[8192];
|
||||
|
||||
return ReceiveAsync(buffer, 0, buffer.Length, cancellationToken);
|
||||
@@ -183,13 +199,20 @@ namespace Emby.Server.Implementations.Net
|
||||
|
||||
public Task SendToAsync(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
var taskCompletion = new TaskCompletionSource<int>();
|
||||
bool isResultSet = false;
|
||||
|
||||
Action<IAsyncResult> callback = callbackResult =>
|
||||
{
|
||||
try
|
||||
{
|
||||
taskCompletion.TrySetResult(EndSendTo(callbackResult));
|
||||
if (!isResultSet)
|
||||
{
|
||||
isResultSet = true;
|
||||
taskCompletion.TrySetResult(EndSendTo(callbackResult));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -202,6 +225,7 @@ namespace Emby.Server.Implementations.Net
|
||||
if (result.CompletedSynchronously)
|
||||
{
|
||||
callback(result);
|
||||
return taskCompletion.Task;
|
||||
}
|
||||
|
||||
cancellationToken.Register(() => taskCompletion.TrySetCanceled());
|
||||
@@ -211,6 +235,8 @@ namespace Emby.Server.Implementations.Net
|
||||
|
||||
public IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, AsyncCallback callback, object state)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
var ipEndPoint = NetworkManager.ToIPEndPoint(endPoint);
|
||||
|
||||
return _Socket.BeginSendTo(buffer, offset, size, SocketFlags.None, ipEndPoint, callback, state);
|
||||
@@ -218,6 +244,8 @@ namespace Emby.Server.Implementations.Net
|
||||
|
||||
public int EndSendTo(IAsyncResult result)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
return _Socket.EndSendTo(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user