Fix Websocket OpenApi (#9935)

* Further split inbound and outbound messages

* Fix datatype for inbound start messages

* fixes from review
This commit is contained in:
Cody Robibero
2023-06-29 05:44:36 -06:00
committed by GitHub
parent 76939bbd9b
commit b5bbb98175
50 changed files with 165 additions and 126 deletions

View File

@@ -9,7 +9,7 @@ using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Extensions.Json;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Net;
using MediaBrowser.Controller.Net.WebSocketMessages;
using MediaBrowser.Model.Session;
using Microsoft.Extensions.Logging;
@@ -85,6 +85,18 @@ namespace Emby.Server.Implementations.HttpServer
/// <value>The state.</value>
public WebSocketState State => _socket.State;
/// <summary>
/// Sends a message asynchronously.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
public Task SendAsync(WebSocketMessage message, CancellationToken cancellationToken)
{
var json = JsonSerializer.SerializeToUtf8Bytes(message, _jsonOptions);
return _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken);
}
/// <summary>
/// Sends a message asynchronously.
/// </summary>
@@ -224,7 +236,7 @@ namespace Emby.Server.Implementations.HttpServer
{
LastKeepAliveDate = DateTime.UtcNow;
return SendAsync(
new WebSocketMessage<string>
new OutboundWebSocketMessage
{
MessageId = Guid.NewGuid(),
MessageType = SessionMessageType.KeepAlive