// Copyright © WireMock.Net using System; using System.Collections.Generic; using JetBrains.Annotations; using WireMock.Models; using WireMock.ResponseProviders; using WireMock.Types; namespace WireMock.ResponseBuilders; /// /// The WebSocket Response Builder interface - allows chainable building of WebSocket responses. /// Implements IResponseProvider to integrate with the response builder chain. /// public interface IWebSocketResponseBuilder : IResponseProvider { /// /// Add a text message to the WebSocket response. /// /// The message text /// Delay in milliseconds before sending /// The response builder for chaining [PublicAPI] IResponseBuilder WithMessage(string message, int delayMs = 0); /// /// Add a JSON message to the WebSocket response. /// /// The object to serialize as JSON /// Delay in milliseconds before sending /// The response builder for chaining [PublicAPI] IResponseBuilder WithJsonMessage(object message, int delayMs = 0); /// /// Add a binary message to the WebSocket response. /// /// The binary data /// Delay in milliseconds before sending /// The response builder for chaining [PublicAPI] IResponseBuilder WithBinaryMessage(byte[] message, int delayMs = 0); /// /// Enable template transformation (Handlebars/Scriban) for messages. /// /// The transformer type to use (default: Handlebars) /// The response builder for chaining [PublicAPI] IResponseBuilder WithTransformer(TransformerType transformerType = TransformerType.Handlebars); /// /// Set the close code and message for connection closure. /// /// The close code (e.g., 1000) /// The close message /// The response builder for chaining [PublicAPI] IResponseBuilder WithClose(int code, string? message = null); /// /// Set the subprotocol to negotiate with client. /// /// The subprotocol name /// The response builder for chaining [PublicAPI] IResponseBuilder WithSubprotocol(string subprotocol); /// /// Set automatic connection closure after all messages are sent. /// /// Delay in milliseconds after last message /// The response builder for chaining [PublicAPI] IResponseBuilder WithAutoClose(int delayMs = 0); /// /// Get the built WebSocket response. /// IWebSocketResponse? Build(); }