mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-14 05:00:24 +02:00
ws2
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Collections.Generic;
|
||||
using WireMock.Types;
|
||||
|
||||
namespace WireMock.WebSockets;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a WebSocket connection request for matching purposes.
|
||||
/// </summary>
|
||||
public class WebSocketConnectRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the request path.
|
||||
/// </summary>
|
||||
public string Path { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request headers.
|
||||
/// </summary>
|
||||
public IDictionary<string, WireMockList<string>> Headers { get; init; } = new Dictionary<string, WireMockList<string>>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the requested subprotocols.
|
||||
/// </summary>
|
||||
public IList<string> SubProtocols { get; init; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the remote address (client IP).
|
||||
/// </summary>
|
||||
public string? RemoteAddress { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the local address (server IP).
|
||||
/// </summary>
|
||||
public string? LocalAddress { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.WebSockets;
|
||||
|
||||
namespace WireMock.WebSockets;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the context for a WebSocket handler.
|
||||
/// </summary>
|
||||
public class WebSocketHandlerContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the WebSocket instance.
|
||||
/// </summary>
|
||||
public WebSocket WebSocket { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request message.
|
||||
/// </summary>
|
||||
public IRequestMessage RequestMessage { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request headers.
|
||||
/// </summary>
|
||||
public IDictionary<string, string[]> Headers { get; init; } = new Dictionary<string, string[]>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subprotocol negotiated for this connection.
|
||||
/// </summary>
|
||||
public string? SubProtocol { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets user state associated with the connection.
|
||||
/// </summary>
|
||||
public IDictionary<string, object> UserState { get; init; } = new Dictionary<string, object>();
|
||||
}
|
||||
42
src/WireMock.Net.WebSockets/Models/WebSocketMessage.cs
Normal file
42
src/WireMock.Net.WebSockets/Models/WebSocketMessage.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Net.WebSockets;
|
||||
|
||||
namespace WireMock.WebSockets;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a WebSocket message.
|
||||
/// </summary>
|
||||
public class WebSocketMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the message type.
|
||||
/// </summary>
|
||||
public string Type { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timestamp when the message was created.
|
||||
/// </summary>
|
||||
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the message data.
|
||||
/// </summary>
|
||||
public object? Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this is a binary message.
|
||||
/// </summary>
|
||||
public bool IsBinary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the raw message content (for binary messages).
|
||||
/// </summary>
|
||||
public byte[]? RawData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text content (for text messages).
|
||||
/// </summary>
|
||||
public string? TextData { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user