73 lines
2.0 KiB
ObjectPascal
73 lines
2.0 KiB
ObjectPascal
unit ProxyServer_Client_Main;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, StdCtrls, uROIndyTCPChannel,
|
|
uROClient, uROBINMessage, ProxyServerMainLibrary_Intf, uROWinMessageChannel;
|
|
|
|
type
|
|
TProxyServer_Client_MainForm = class(TForm)
|
|
ROBINMessage: TROBINMessage;
|
|
ROIndyTCPChannel: TROIndyTCPChannel;
|
|
Label1: TLabel;
|
|
cbServer: TComboBox;
|
|
SumButton: TButton;
|
|
GetServerTimeButton: TButton;
|
|
EchoStructButton: TButton;
|
|
ROWinMessageChannel: TROWinMessageChannel;
|
|
procedure SumButtonClick(Sender: TObject);
|
|
procedure GetServerTimeButtonClick(Sender: TObject);
|
|
procedure EchoStructButtonClick(Sender: TObject);
|
|
private
|
|
function CreateService: IProxyServerMainService;
|
|
public
|
|
|
|
end;
|
|
|
|
var
|
|
ProxyServer_Client_MainForm: TProxyServer_Client_MainForm;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
function TProxyServer_Client_MainForm.CreateService: IProxyServerMainService;
|
|
begin
|
|
if cbServer.ItemIndex = 0 then
|
|
result := CoProxyServerMainService.Create(ROBINMessage, ROIndyTCPChannel) // TCP over main one
|
|
else
|
|
result := CoProxyServerMainService.Create(ROBINMessage, ROWinMessageChannel) // Windows messages to proxy
|
|
end;
|
|
|
|
procedure TProxyServer_Client_MainForm.SumButtonClick(Sender: TObject);
|
|
begin
|
|
ShowMessage('Result is ' + IntToStr(CreateService.Sum(1, 2)));
|
|
end;
|
|
|
|
procedure TProxyServer_Client_MainForm.GetServerTimeButtonClick(Sender: TObject);
|
|
begin
|
|
ShowMessage('Time is ' + DateTimeToStr(CreateService.GetServerTime));
|
|
end;
|
|
|
|
procedure TProxyServer_Client_MainForm.EchoStructButtonClick(Sender: TObject);
|
|
var
|
|
out_struct, in_struct: TestStruct;
|
|
begin
|
|
in_struct := nil;
|
|
out_struct := TestStruct.Create;
|
|
out_struct.Name := 'Dave Fuller';
|
|
out_struct.IntNumber := 666;
|
|
try
|
|
in_struct := CreateService.EchoStruct(out_struct);
|
|
ShowMessage(out_struct.Name + ', ' + IntToStr(out_struct.IntNumber));
|
|
finally
|
|
if in_struct <> nil then in_struct.Free;
|
|
out_struct.Free;
|
|
end;
|
|
end;
|
|
|
|
end.
|
|
|