diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2020-05-26 20:00:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-26 20:00:01 -0400 |
| commit | 7c72f69189500ef491a0e81d8ce6788987f47fa3 (patch) | |
| tree | d8dbb903a3f1a1334f04d447ade715b102e8be99 /Emby.Server.Implementations/HttpServer/WebSocketConnection.cs | |
| parent | b33fa06efa1c7bf334bc0bcf7e845d86dffe12da (diff) | |
| parent | e42bfc92f3e072a3d51dddce06bc90587e06791c (diff) | |
Merge pull request #2733 from OancaAndrei/syncplay
Add syncplay feature
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(); + } } } } |
