sgcWebSockets · Technical Document

DataSnap — HTTP.sys WebSocket + HTTP/2

TsgcWSServer_HTTPAPI_WebBrokerBridge — kernel-mode (http.sys) WebBroker / DataSnap host with WebSocket and HTTP/2 transports.

Overview

TsgcWSServer_HTTPAPI_WebBrokerBridge use TsgcWebSocketServer_HTTPAPI with HTTP/2 protocol enabled as server base and is useful if you want to use a single server for DataSnap, HTTP/2 and WebSocket connections.

At a glance

Component class
TsgcWSServer_HTTPAPI_WebBrokerBridge
Standards / spec
WebSocket Protocol — RFC 6455
Transports
TCP, TLS, HTTP, HTTPS
Platforms
Windows, macOS, Linux, iOS, Android
Frameworks
VCL, FireMonkey, Lazarus / FPC
Edition
Standard / Professional / Enterprise

Features

Technical specification

Standards & specsWebSocket Protocol — RFC 6455 · HTTP/2 — RFC 9113
Component classTsgcWSServer_HTTPAPI_WebBrokerBridge (unit sgcWebSocket_HTTPAPI_WebBrokerBridge)
FrameworksVCL, FireMonkey, Lazarus / FPC
PlatformsWindows, macOS, Linux, iOS, Android

Main properties

The principal published / public properties used to configure and drive the component. Consult the online help for the full list.

APIKeyManagerPublished or public property used to configure or query the component.
DefaultPortPublished or public property used to configure or query the component.
BindingOptionsPublished or public property used to configure or query the component.
SSLOptionsPublished or public property used to configure or query the component.
OnCommandRequestPublished or public property used to configure or query the component.
TimeoutsPublished or public property used to configure or query the component.
FineTunePublished or public property used to configure or query the component.
AsynchronousPublished or public property used to configure or query the component.
MaxConnectionsPublished or public property used to configure or query the component.
MaxBandwidthPublished or public property used to configure or query the component.

Main methods

The principal public methods exposed by the component.

Start()Public procedure exposed by the component.
Stop()Public procedure exposed by the component.
ReStart()Public procedure exposed by the component.
ShareList()Public function exposed by the component.
UnShareList()Public procedure exposed by the component.
LockList()Public function exposed by the component.
UnLockList()Public procedure exposed by the component.
RegisterWebModuleClass()Public procedure exposed by the component.

Quick Start

Drop the component on a form, configure the properties below and activate it. The snippet that follows shows the typical Load Balancer configuration sourced from the online help.

About this scenario. If the server is behind the TsgcWebSocketLoadBalancerServer, you may have issues with CORS, to avoid these issues, use the following code

Delphi (VCL / FireMonkey)

procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
 Response.SetCustomHeader('Access-Control-Allow-Origin','*');    
 if Trim(Request.GetFieldByName('Access-Control-Request-Headers')) <> '' then
 begin
  Response.SetCustomHeader('Access-Control-Allow-Headers', Request.GetFieldByName('Access-Control-Request-Headers'));    
  Handled := True;
 end;
 if FServerFunctionInvokerAction <> nil then
  FServerFunctionInvokerAction.Enabled := AllowServerFunctionInvoker;
end;

C++ Builder

void __fastcall TWebModule1::WebModuleBeforeDispatch(TObject *Sender, TWebRequest *Request, TWebResponse *Response, bool &Handled)
{
  Response->SetCustomHeader("Access-Control-Allow-Origin", "*");
  if (Trim(Request->GetFieldByName("Access-Control-Request-Headers")) != "")
  {
    Response->SetCustomHeader("Access-Control-Allow-Headers", Request->GetFieldByName("Access-Control-Request-Headers"));
    Handled = true;
  }
  if (FServerFunctionInvokerAction != nullptr)
  {
    FServerFunctionInvokerAction->Enabled = AllowServerFunctionInvoker;
  }
}

.NET (C#)

void WebModuleBeforeDispatch(object Sender, TWebRequest Request, TWebResponse Response, ref bool Handled)
{
  Response.SetCustomHeader("Access-Control-Allow-Origin", "*");
  if (Request.GetFieldByName("Access-Control-Request-Headers").Trim() != "")
  {
    Response.SetCustomHeader("Access-Control-Allow-Headers", Request.GetFieldByName("Access-Control-Request-Headers"));
    Handled = true;
  }
  if (FServerFunctionInvokerAction != null)
  {
    FServerFunctionInvokerAction.Enabled = AllowServerFunctionInvoker;
  }
}

Sources used to build this document

Every external claim links back to a primary source. The online-help references decode the canonical deep-link the company maintains for this component.

Document scope. This document covers the publicly-documented surface of the DataSnap — HTTP.sys WebSocket + HTTP/2 component shipped with sgcWebSockets. For full property, method and event reference consult the online help linked above.