1. Połącz się z serwerem WebSocket
Użyj TsgcWebSocketClient, aby połączyć się z dowolnym serwerem zgodnym z RFC 6455, wysłać wiadomość i reagować na przychodzące ramki.
uses
sgcWebSocket;
var
oClient: TsgcWebSocketClient;
begin
oClient := TsgcWebSocketClient.Create(nil);
try
oClient.URL := 'wss://echo.websocket.org';
oClient.WatchDog.Enabled := True; // auto-reconnect
oClient.OnMessage := procedure(Connection: TsgcWSConnection;
const Text: string)
begin
Writeln('Server says: ', Text);
end;
oClient.Active := True;
oClient.WriteData('Hello from Delphi!');
Readln;
finally
oClient.Free;
end;
end;
2. Wygeneruj klienta REST Delphi z OpenAPI
Wskaż TsgcOpenAPI_Generator na dowolną specyfikację OpenAPI 3 (plik lokalny lub URL HTTP) i wyemituj typowanego klienta Delphi — klasy, metody, auth i DTO żądania/odpowiedzi — w jednym wywołaniu.
uses
sgcOpenAPI_Parser, sgcOpenAPI_Generator;
var
oGen: TsgcOpenAPI_Generator;
begin
oGen := TsgcOpenAPI_Generator.Create(nil);
try
oGen.Source := 'https://petstore3.swagger.io/api/v3/openapi.json';
oGen.OutputFolder := 'C:\Projects\PetStoreClient\src';
oGen.Language := lngDelphi;
oGen.Namespace := 'PetStore.Client';
oGen.Generate;
Writeln('Generated ', oGen.Files.Count, ' Delphi units');
finally
oGen.Free;
end;
end;
3. Podpisz PDF
Użyj TsgcSignPDF, aby wytworzyć podpis zgodny z PAdES z certyfikatem od dowolnego z wspieranych dostawców kluczy (PKCS#11, Azure Key Vault, AWS KMS, Windows Cert Store, lokalny PFX).
uses
sgcSign_PAdES, sgcSign_KeyProvider_Windows;
var
oSigner: TsgcSignPDF;
oKey : TsgcSign_KeyProvider_Windows;
begin
oKey := TsgcSign_KeyProvider_Windows.Create(nil);
oKey.CertificateThumbprint := 'a1b2c3d4...';
oSigner := TsgcSignPDF.Create(nil);
try
oSigner.KeyProvider := oKey;
oSigner.Profile := 'PAdES-B-LT';
oSigner.SignFile(
'C:\docs\contract.pdf',
'C:\docs\contract.signed.pdf');
Writeln('Signed: ', oSigner.LastSignatureId);
finally
oSigner.Free;
oKey.Free;
end;
end;