TsgcWSHTTP2WebBrokerBridgeServer

TsgcWSHTTP2WebBrokerBridgeServerHTTP/2 프로토콜이 활성화된 TsgcWebSocketHTTPServer 서버 기반으로 사용하며, DataSnap, HTTP/2 및 WebSocket 연결에 단일 서버를 사용하려는 경우 유용합니다.

 

TsgcWSHTTP2WebBrokerBridgeServerTsgcWebSocketHTTPServer에서 상속되므로, 이 서버를 참조할 수 있습니다.

 

TIdHttpWebBrokerBridgeTsgcWSHTTP2WebBrokerBridgeServer로 교체하려면 다음 단계를 따르십시오:

 

1. TsgcWSHTTP2WebBrokerBridgeServer의 새 인스턴스를 생성하십시오.

 

2. TIdHttpWebBrokerBridge에 대한 모든 호출을 TsgcWSHTTP2WebBrokerBridgeServer로 교체하십시오.

 

3. WebSocket 연결을 처리하려면 TsgcWebSocketHTTPServer를 참조하십시오.

 

구성

Datasnap 구성 요소는 Source 폴더에만 위치합니다. 이 객체들은 sgcWebSockets 패키지에 포함되지 않으므로 컴파일된 폴더에서는 찾을 수 없으며, 런타임에 생성해야 합니다.

필요한 파일을 프로젝트에 추가하거나 sgcWebSockets 패키지의 Source 폴더로 경로를 설정하기만 하면 됩니다. 필요한 파일:

 

 

프로젝트가 IdHTTPWebBrokerBridge를 사용하는 경우 sgcIdHTTPWebBrokerBridge로 변경하십시오(이는 Enterprise Edition에만 적용됩니다).

Events


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;