TsgcWSPClient_E2EEMethods › SendDirectMessage

SendDirectMessage Method

Sends an encrypted direct message (text, stream or bytes) to a remote user.

Overloads

Overload 1

Syntax

function SendDirectMessage(const aTo, aText: string): string;

Parameters

NameTypeDescription
aToconst stringUserId of the destination peer as registered on the server.
aTextconst stringPlain text payload. Content is encrypted on this client before being sent.

Return Value

Message identifier used to correlate the send with OnE2EEMessageAck. Empty when the message could not be queued (string).

Remarks

Encrypts aText with the session key agreed with aTo and sends it over the underlying WebSocket. The remote peer receives the decrypted payload through OnE2EEMessageText. If E2EE_Options.Ack.RcvDirectMessage is enabled on the recipient, this side receives OnE2EEMessageAck with the returned identifier.

Example

oE2EE.SendDirectMessage('CLIENT02', 'Hello direct');

Overload 2

Syntax

function SendDirectMessage(const aTo: string; const aStream: TStream) : string;

Parameters

NameTypeDescription
aToconst stringUserId of the destination peer as registered on the server.
aStreamconst TStreamStream containing the binary payload. The entire stream content is read and encrypted; position is not preserved.

Return Value

Message identifier used to correlate the send with OnE2EEMessageAck. Empty when the message could not be queued (string).

Remarks

Same as the text overload, but sends binary content from a stream. The recipient receives the decrypted bytes through OnE2EEMessageBinary. Use this form when the payload is already available as a TStream (for example a file or a memory buffer).

Example

oStream := TFileStream.Create('photo.jpg', fmOpenRead);
try
  oE2EE.SendDirectMessage('CLIENT02', oStream);
finally
  oStream.Free;
end;

Back to Methods