Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ OnKeepAlive()

static async void System.Net.WebSockets.WebSocketBase.OnKeepAlive ( object sender)
inlinestaticprivate

Definition at line 1674 of file WebSocketBase.cs.

1675 {
1677 bool lockTaken = false;
1679 try
1680 {
1681 Monitor.Enter(thisPtr.SessionHandle, ref lockTaken);
1682 if (thisPtr._isDisposed || thisPtr._state != WebSocketState.Open || thisPtr._closeOutputTask != null || !thisPtr._keepAliveTracker.ShouldSendKeepAlive())
1683 {
1684 return;
1685 }
1686 bool ownsCancellationTokenSource = false;
1687 try
1688 {
1689 ownsCancellationTokenSource = thisPtr._sendOutstandingOperationHelper.TryStartOperation(CancellationToken.None, out linkedCancellationToken);
1691 {
1692 thisPtr.EnsureKeepAliveOperation();
1693 thisPtr._keepAliveTask = thisPtr._keepAliveOperation.Process(null, linkedCancellationToken);
1694 ReleaseLock(thisPtr.SessionHandle, ref lockTaken);
1695 await thisPtr._keepAliveTask.SuppressContextFlow();
1696 }
1697 }
1698 finally
1699 {
1700 if (!lockTaken)
1701 {
1702 Monitor.Enter(thisPtr.SessionHandle, ref lockTaken);
1703 }
1704 thisPtr._sendOutstandingOperationHelper.CompleteOperation(ownsCancellationTokenSource);
1705 thisPtr._keepAliveTask = null;
1706 }
1707 thisPtr._keepAliveTracker.ResetTimer();
1708 }
1709 catch (Exception exception)
1710 {
1711 try
1712 {
1713 thisPtr.ThrowIfConvertibleException("OnKeepAlive", exception, CancellationToken.None, linkedCancellationToken.IsCancellationRequested);
1714 throw;
1715 }
1716 catch (Exception exception2)
1717 {
1718 thisPtr.OnBackgroundTaskException(exception2);
1719 }
1720 }
1721 finally
1722 {
1723 ReleaseLock(thisPtr.SessionHandle, ref lockTaken);
1724 }
1725 }
static void ReleaseLock(object lockObject, ref bool lockTaken)
WebSocketBase(Stream innerStream, string subProtocol, TimeSpan keepAliveInterval, WebSocketBuffer internalBuffer)
static void Enter(object obj)

References System.Net.WebSockets.WebSocketBase.WebSocketBase(), System.Threading.Monitor.Enter(), System.exception, System.Threading.CancellationToken.None, and System.Net.WebSockets.WebSocketBase.ReleaseLock().