This commit is contained in:
Stef Heyenrath
2026-02-12 18:22:59 +01:00
parent e4ebdfba76
commit 37201bd65c
12 changed files with 93 additions and 326 deletions

View File

@@ -20,7 +20,7 @@ public static class Program
Console.WriteLine("Choose an example to run:");
Console.WriteLine("1. Echo Server");
Console.WriteLine("2. Custom Message Handler");
Console.WriteLine("3. Broadcast Server");
Console.WriteLine("3. ...");
Console.WriteLine("4. Scenario/State Machine");
Console.WriteLine("5. WebSocket Proxy");
Console.WriteLine("6. Multiple WebSocket Endpoints");
@@ -419,28 +419,6 @@ public static class Program
)
);
// Endpoint 3: JSON service
server
.Given(Request.Create()
.WithPath("/ws/json")
.WithWebSocketUpgrade()
)
.RespondWith(Response.Create()
.WithWebSocket(ws => ws
.WithMessageHandler(async (msg, ctx) =>
{
var response = new
{
timestamp = DateTime.UtcNow,
message = msg.Text,
length = msg.Text?.Length ?? 0,
type = msg.MessageType.ToString()
};
await ctx.SendAsJsonAsync(response);
})
)
);
// Endpoint 4: Protocol-specific
server
.Given(Request.Create()
@@ -586,27 +564,6 @@ public static class Program
})
)
);
// JSON endpoint
server
.Given(Request.Create()
.WithPath("/ws/json")
.WithWebSocketUpgrade()
)
.RespondWith(Response.Create()
.WithWebSocket(ws => ws
.WithMessageHandler(async (msg, ctx) =>
{
var response = new
{
timestamp = DateTime.UtcNow,
message = msg.Text,
connectionId = ctx.ConnectionId
};
await ctx.SendAsJsonAsync(response);
})
)
);
}
private static void SetupGameScenario(WireMockServer server)