TsgcWSHTTP2WebBrokerBridgeServer

TsgcWSHTTP2WebBrokerBridgeServer, sunucu tabanı olarak HTTP/2 protokolü etkin TsgcWebSocketHTTPServer kullanır ve DataSnap, HTTP/2 ve WebSocket bağlantıları için tek bir sunucu kullanmak istiyorsanız kullanışlıdır.

 

TsgcWSHTTP2WebBrokerBridgeServer, TsgcWebSocketHTTPServer öğesinden devralır, böylece bu sunucuya başvurabilirsiniz.

 

TIdHttpWebBrokerBridge'i TsgcWSHTTP2WebBrokerBridgeServer ile değiştirmek için sonraki adımları izleyin :

 

1. TsgcWSHTTP2WebBrokerBridgeServer'ın yeni bir örneğini oluşturun.

 

2. TIdHttpWebBrokerBridge'e yapılan tüm çağrıları TsgcWSHTTP2WebBrokerBridgeServer ile değiştirin.

 

3. WebSocket bağlantılarını işlemek için yalnızca TsgcWebSocketHTTPServer öğesine başvurun.

 

Configuration

Datasnap bileşenleri yalnızca Source klasöründe bulunur, derlenmiş klasörlerde bulamazsınız çünkü bu nesneler sgcWebSockets paketine dahil değildir, bu nedenle çalışma zamanında oluşturmanız gerekir.

Yalnızca gerekli dosyaları projenize ekleyin veya yolunuzu sgcWebSockets paketinin Source klasörüne ayarlayın. Gerekli dosyalar:

 

 

Proje IdHTTPWebBrokerBridge kullanıyorsa sgcIdHTTPWebBrokerBridge'e geçin (bu yalnızca Enterprise Edition için geçerlidir).

Olaylar


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;