TsgcWSPClient_WAMPMethods › WriteData

WriteData Method

Sends a pre-built text or binary WAMP frame directly over the underlying WebSocket transport.

Overloads

Overload 1

Syntax

procedure WriteData(const aText: String);

Parameters

NameTypeDescription
aTextconst StringReady-to-send WAMP JSON text frame (for example [2,"id","proc"] for a CALL). Transmitted verbatim as a WebSocket text frame.

Remarks

Low-level escape hatch for emitting experimental or server-specific WAMP messages that the high-level API (Call, Subscribe, Publish, etc.) does not expose. The text is written verbatim, so the caller is responsible for producing a well-formed WAMP array payload. Misuse can desynchronise the session or cause the server to disconnect the client.

Example


// send a hand-crafted WAMP PREFIX frame
WAMP.WriteData('[1,"calc","http://example.com/simple/calc#"]');

Overload 2

Syntax

procedure WriteData(aStream: TStream; aSize: Integer = 0; const aStreaming: TwsStreaming = stmNone);

Parameters

NameTypeDescription
aStreamTStreamSource stream whose bytes are sent as a binary WebSocket frame. The current position is respected and the stream is read forward.
aSizeIntegerNumber of bytes to send from the current position. Pass 0 to transmit from the current position to the end of the stream.
aStreamingconst TwsStreamingFragmentation mode: stmNone sends the payload as a single frame; stmStart, stmContinue and stmEnd emit WebSocket continuation frames when the payload is split into chunks.

Remarks

Binary companion of the text overload. WAMP v1 is a JSON-over-text protocol, so this form is intended for companion payloads (for example hand-crafted ping frames, out-of-band file transfers or experimental extensions) rather than standard RPC/PubSub traffic. Bypasses all WAMP bookkeeping — no OnCallResult, OnCallError or OnEvent correlation is performed for data sent this way.

Example


var
  oStream: TFileStream;
begin
  oStream := TFileStream.Create('payload.bin', fmOpenRead);
  try
    WAMP.WriteData(oStream);
  finally
    oStream.Free;
  end;
end;

Back to Methods