Skip to content

Commit d98590c

Browse files
committed
Document existing websocket callback threading contract
1 parent 02e3896 commit d98590c

1 file changed

Lines changed: 36 additions & 4 deletions

File tree

Include/httpClient/httpClient.h

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,14 @@ STDAPI HCHttpCallResponseGetHeaderAtIndex(
903903
/// <summary>
904904
/// A callback invoked every time a WebSocket receives an incoming message
905905
/// </summary>
906+
/// <remarks>
907+
/// This callback is not guaranteed to be dispatched through the XTaskQueue associated with
908+
/// HCWebSocketConnectAsync() or any XTaskQueue completion port. It may be invoked on a
909+
/// provider-managed or otherwise implementation-defined thread.
910+
///
911+
/// Handlers are responsible for any required thread safety or marshalling to an execution context
912+
/// of their choosing.
913+
/// </remarks>
906914
/// <param name="websocket">Handle to the WebSocket that this message was sent to</param>
907915
/// <param name="incomingBodyString">UTF-8 encoded body of the incoming message as a string value, only if the message type is UTF-8.</param>
908916
/// <param name="functionContext">Client context to pass to callback function.</param>
@@ -916,6 +924,14 @@ typedef void
916924
/// <summary>
917925
/// A callback invoked every time a WebSocket receives an incoming binary message
918926
/// </summary>
927+
/// <remarks>
928+
/// This callback is not guaranteed to be dispatched through the XTaskQueue associated with
929+
/// HCWebSocketConnectAsync() or any XTaskQueue completion port. It may be invoked on a
930+
/// provider-managed or otherwise implementation-defined thread.
931+
///
932+
/// Handlers are responsible for any required thread safety or marshalling to an execution context
933+
/// of their choosing.
934+
/// </remarks>
919935
/// <param name="websocket">Handle to the WebSocket that this message was sent to</param>
920936
/// <param name="incomingBodyPayload">Binary message payload.</param>
921937
/// <param name="incomingBodyPayloadSize">Size of the payload in bytes.</param>
@@ -934,14 +950,22 @@ typedef void
934950
///
935951
/// The callback receives raw bytes. In legacy Win32 / GDK behavior, oversized UTF-8 payloads use
936952
/// this same fragment path.
953+
/// </summary>
954+
/// <remarks>
955+
/// This callback is not guaranteed to be dispatched through the XTaskQueue associated with
956+
/// HCWebSocketConnectAsync() or any XTaskQueue completion port. It may be invoked on a
957+
/// provider-managed or otherwise implementation-defined thread.
958+
///
959+
/// Handlers are responsible for any required thread safety or marshalling to an execution context
960+
/// of their choosing.
937961
///
938-
/// IMPORTANT: If you expect incoming payloads larger than the receive buffer, set this callback or
939-
/// raise the receive buffer with HCWebSocketSetMaxReceiveBufferSize(). Without this callback,
940-
/// oversized payloads are not surfaced through the public whole-message callbacks.
962+
/// If you expect incoming payloads larger than the receive buffer, set this callback or raise the
963+
/// receive buffer with HCWebSocketSetMaxReceiveBufferSize(). Without this callback, oversized
964+
/// payloads are not surfaced through the public whole-message callbacks.
941965
///
942966
/// Typical usage: Accumulate fragments in a buffer until isLastFragment is true, then process the
943967
/// complete payload.
944-
/// </summary>
968+
/// </remarks>
945969
/// <param name="websocket">Handle to the WebSocket that this message was sent to</param>
946970
/// <param name="payloadBytes">Binary message fragment payload.</param>
947971
/// <param name="payloadSize">Size of this fragment in bytes.</param>
@@ -959,6 +983,14 @@ typedef void
959983
/// <summary>
960984
/// A callback invoked when a WebSocket is closed
961985
/// </summary>
986+
/// <remarks>
987+
/// This callback is not guaranteed to be dispatched through the XTaskQueue associated with
988+
/// HCWebSocketConnectAsync() or any XTaskQueue completion port. It may be invoked when the close
989+
/// event is observed on a provider-managed or otherwise implementation-defined thread.
990+
///
991+
/// Handlers are responsible for any required thread safety or marshalling to an execution context
992+
/// of their choosing.
993+
/// </remarks>
962994
/// <param name="websocket">Handle to the WebSocket</param>
963995
/// <param name="closeStatus">The status of why the WebSocket was closed</param>
964996
/// <param name="functionContext">Client context to pass to callback function.</param>

0 commit comments

Comments
 (0)