TsgcWSHTTP2WebBrokerBridgeServer

TsgcWSHTTP2WebBrokerBridgeServer utilizza TsgcWebSocketHTTPServer con HTTP/2 protocollo abilitato come base del server ed è utile se desidera utilizzare un singolo server per connessioni DataSnap, HTTP/2 e WebSocket.

 

TsgcWSHTTP2WebBrokerBridgeServer eredita da TsgcWebSocketHTTPServer, pertanto è possibile fare riferimento a questo server.

 

Seguire i passaggi successivi per sostituire TIdHttpWebBrokerBridge con TsgcWSHTTP2WebBrokerBridgeServer:

 

1. Crea una nuova istanza di TsgcWSHTTP2WebBrokerBridgeServer.

 

2. Sostituire tutte le chiamate a TIdHttpWebBrokerBridge con TsgcWSHTTP2WebBrokerBridgeServer.

 

3. Per gestire le connessioni WebSocket faccia semplicemente riferimento a TsgcWebSocketHTTPServer.

 

Configurazione

I componenti Datasnap si trovano solo nella cartella Source; non saranno trovati nelle cartelle compilate perché questi oggetti non sono inclusi nel pacchetto sgcWebSockets, quindi devono essere creati in fase di esecuzione.

Aggiungere semplicemente i file richiesti al progetto o impostare il percorso alla cartella Source del pacchetto sgcWebSockets. File richiesti:

 

 

Se il progetto utilizza IdHTTPWebBrokerBridge passi a sgcIdHTTPWebBrokerBridge (questo si applica solo per l'Enterprise Edition).

Eventi


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;