TsgcWSHTTP2WebBrokerBridgeServer use TsgcWebSocketHTTPServer 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.
TsgcWSHTTP2WebBrokerBridgeServer inherits from TsgcWebSocketHTTPServer, so you can refer to this server.
Follow next steps to replace TIdHttpWebBrokerBridge for TsgcWSHTTP2WebBrokerBridgeServer :
1. Create a new instance of TsgcWSHTTP2WebBrokerBridgeServer.
2. Replace all calls to TIdHttpWebBrokerBridge for TsgcWSHTTP2WebBrokerBridgeServer.
3. To Handle WebSocket connections just refer to TsgcWebSocketHTTPServer.
The Datasnap components are only located in Source folder, you won't find in the compiled folders because these objects are not included in sgcWebSockets package, so you must create in runtime.
Just add the required files to your project or set your path to the Source folder of sgcWebSockets package. Files required:
If the project makes uses of IdHTTPWebBrokerBridge change to sgcIdHTTPWebBrokerBridge (this only applies for Enterprise Edition).
FServer := TsgcWSHTTP2WebBrokerBridgeServer.Create(Self);
FServer.OnCommandRequest := OnCommandRequestEvent;
FServer.OnCommandGet := OnCommandGetevent;
procedure OnCommandRequestEvent(AThread: TIdContext; ARequestInfo: TIdHTTPRequestInfo;
AResponseInfo: TIdHTTPResponseInfo; var aHandled: Boolean);
begin
if ARequestInfo.Document = '/test.html' then
aHandled := True;
end;
procedure OnCommandGetevent(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo;
AResponseInfo: TIdHTTPResponseInfo);
begin
if ARequestInfo.Document = '/test.html' then
begin
AResponseInfo.ResponseNo := 200;
AResponseInfo.ContentText := 'hello all';
end;
end;