diff options
| author | Patrick Barron <barronpm@gmail.com> | 2020-05-26 20:29:11 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-05-26 20:29:11 -0400 |
| commit | 01ce56016a3e7189cf29b22b095dc15b82a19303 (patch) | |
| tree | d627726db3424ac1ae3c47fde44644462a3e5a27 /Emby.Server.Implementations/HttpServer/WebSocketConnection.cs | |
| parent | e052128c527672ed586a78257da1d2b07319e598 (diff) | |
| parent | 7c72f69189500ef491a0e81d8ce6788987f47fa3 (diff) | |
Merge branch 'master' into userdb-efcore
# Conflicts:
# Emby.Server.Implementations/Library/UserManager.cs
# Jellyfin.Data/Jellyfin.Data.csproj
# MediaBrowser.Api/UserService.cs
# MediaBrowser.Controller/Library/IUserManager.cs
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/WebSocketConnection.cs')
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/WebSocketConnection.cs | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index 095725c50..0680c5ffe 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -78,6 +78,9 @@ namespace Emby.Server.Implementations.HttpServer /// <value>The last activity date.</value> public DateTime LastActivityDate { get; private set; } + /// <inheritdoc /> + public DateTime LastKeepAliveDate { get; set; } + /// <summary> /// Gets or sets the query string. /// </summary> @@ -218,7 +221,42 @@ namespace Emby.Server.Implementations.HttpServer Connection = this }; - await OnReceive(info).ConfigureAwait(false); + if (info.MessageType.Equals("KeepAlive", StringComparison.Ordinal)) + { + await SendKeepAliveResponse(); + } + else + { + await OnReceive(info).ConfigureAwait(false); + } + } + + private Task SendKeepAliveResponse() + { + LastKeepAliveDate = DateTime.UtcNow; + return SendAsync(new WebSocketMessage<string> + { + MessageType = "KeepAlive" + }, CancellationToken.None); + } + + /// <inheritdoc /> + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// <summary> + /// Releases unmanaged and - optionally - managed resources. + /// </summary> + /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> + protected virtual void Dispose(bool dispose) + { + if (dispose) + { + _socket.Dispose(); + } } } } |
