mirror of
https://github.com/yawaflua/WebSockets.git
synced 2026-02-04 14:04:11 +02:00
35 lines
935 B
C#
35 lines
935 B
C#
using System.Net.WebSockets;
|
|
using Microsoft.AspNetCore.Http;
|
|
using yawaflua.WebSockets.Models.Interfaces;
|
|
|
|
namespace yawaflua.WebSockets.Models;
|
|
|
|
internal class WebSocketClient : IWebSocketClient
|
|
{
|
|
private HttpContext HttpContext { get; set; }
|
|
public Guid Id { get; } = Guid.NewGuid();
|
|
public string Path { get; }
|
|
public ConnectionInfo ConnectionInfo => HttpContext.Connection;
|
|
|
|
public IDictionary<object, object>? Items
|
|
{
|
|
get => HttpContext.Items;
|
|
set => HttpContext.Items = value;
|
|
}
|
|
|
|
public HttpRequest HttpRequest => HttpContext.Request;
|
|
public WebSocket webSocket { get; }
|
|
|
|
internal WebSocketClient(HttpContext httpContext, WebSocket webSocket, string path)
|
|
{
|
|
this.webSocket = webSocket;
|
|
Path = path;
|
|
this.HttpContext = httpContext;
|
|
}
|
|
|
|
public Task Abort()
|
|
{
|
|
webSocket.Abort();
|
|
return Task.CompletedTask;
|
|
}
|
|
} |