TsgcWebSocketClient › プロパティ › Options
ハンドシェイクヘッダーをカスタマイズし、フラグメンテーションや UTF-8 検証などのクライアントの動作を微調整します。
property Options: TsgcWSOptionsClient read FOptions write SetOptions;
FragmentedMessages=frgOnlyBuffer, RaiseDisconnectExceptions=True, ValidateUTF8=False, CleanDisconnect=False, WaitForConnect=False
ハンドシェイクとランタイム設定を公開します: Parameters(追加の GET パラメータ)、Origin(カスタム Origin ヘッダー)、および FragmentedMessages(フラグメントをバッファリング(frgOnlyBuffer)、個別に報告(frgOnlyFragmented)、または両方(frgAll))。RaiseDisconnectExceptions はプロトコルエラー切断で例外を発生させ、ValidateUTF8 はテキストフレームの UTF-8 準拠を検証し、CleanDisconnect は TCP セッションを切断する前にクローズフレームを送信します。
WaitForConnect controls when the synchronous Connect call returns. By default (False) Connect returns as soon as the WebSocket transport is connected, which can be before the OnConnect event has fired. When set to True, Connect returns only after the OnConnect event has run, so for a sub-protocol that establishes a session on connect (for example the sgc protocol, which assigns a session in its OnConnect) the connection is fully ready as soon as Connect returns. This avoids a connect-readiness race on fast reconnects, where code that inspects the connection immediately after Connect could run before the sub-protocol OnConnect had fired. It applies when NotifyEvents is neNoSync, where events run inline on the read thread. With neAsynchronous the OnConnect event is queued to the main thread and cannot be awaited inside Connect, so use the OnConnect event to detect readiness in that case.
oClient := TsgcWebSocketClient.Create(nil);
oClient.URL := 'wss://www.esegece.com:2053';
oClient.Options.Parameters := '/ws/';
oClient.Options.ValidateUTF8 := true;
oClient.Options.CleanDisconnect := true;
oClient.Options.WaitForConnect := true;
oClient.Active := true;