Componentes.Terceros.RemObj.../internal/5.0.23.613/1/RemObjects SDK for Delphi/Samples/Multi Channel/MultiChannel_ClientMain.pas
david 2824855ea7 - Modificación del paquete RemObjects_Core_D10 para que sea un paquete de runtime/designtime (antes era designtime sólo)
- Recompilación en Delphi10 de todos los paquetes de RO para generar las DCU's en Lib\D10
- Recompilación en Delphi10 de todos los paquetes de DA para generar las DCU's en Lib\D10

git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.RemObjects@9 b6239004-a887-0f4b-9937-50029ccdca16
2007-09-10 14:06:19 +00:00

134 lines
3.8 KiB
ObjectPascal

unit MultiChannel_ClientMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
StdCtrls, MultiChannelLibrary_Intf, MultiChannel_ClientData, SyncObjs,
uROIndyUDPChannel, uROSuperTCPChannel, uROIndyTCPChannel,
uROLocalChannel, uRODLLChannel, uRONamedPipeChannel,
uROWinMessageChannel, uROClient, uROWinInetHttpChannel, uROBinMessage,
uRORemoteService, ExtCtrls;
type
TMultiChannel_ClientMainForm = class(TForm)
RemoteService: TRORemoteService;
BinMessage: TROBinMessage;
WinInetHTTPChannel: TROWinInetHTTPChannel;
WinMessageChannel: TROWinMessageChannel;
NamedPipeChannel: TRONamedPipeChannel;
DLLChannel: TRODLLChannel;
LocalChannel: TROLocalChannel;
IndyTCPChannel: TROIndyTCPChannel;
SuperTcpChannel: TROSuperTcpChannel;
IndyUDPChannel: TROIndyUDPChannel;
Memo: TMemo;
Panel1: TPanel;
GetServerTimeButton: TButton;
rgConnect: TRadioGroup;
procedure GetServerTimeButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
CriticalSection: TCriticalSection;
function GetMultiChannelService: IMultiChannelService;
{ Private declarations }
public
procedure Log(Astr: string);
{ Public declarations }
end;
var
MultiChannel_ClientMainForm: TMultiChannel_ClientMainForm;
implementation
{$R *.dfm}
function TMultiChannel_ClientMainForm.GetMultiChannelService: IMultiChannelService;
const
atargetUrl = 'http://localhost:%d/BIN';
aHost = '127.0.0.1';
begin
case rgConnect.ItemIndex of
{IndyHTTPServer} 0: begin
RemoteService.Channel := WinInetHTTPChannel;
WinInetHTTPChannel.TargetURL := Format(atargetUrl, [8099]);
end;
{BPDXHTTPServer} 1: begin
RemoteService.Channel := WinInetHTTPChannel;
WinInetHTTPChannel.TargetURL := Format(atargetUrl, [8098]);
end;
{SuperTcpServer} 2: begin
RemoteService.Channel := SuperTcpChannel;
SuperTcpChannel.Host := aHost;
end;
{IndyTCPServer} 3: begin
RemoteService.Channel := IndyTCPChannel;
IndyTCPChannel.Host := aHost;
IndyTCPChannel.Port := 8090;
end;
{BPDXTCPServer} 4: begin
RemoteService.Channel := IndyTCPChannel;
IndyTCPChannel.Host := aHost;
IndyTCPChannel.Port := 8089;
end;
{LocalServer} 5: begin
RemoteService.Channel := LocalChannel;
end;
{IndyUDPServer} 6: begin
RemoteService.Channel := IndyUDPChannel;
IndyUDPChannel.Host := aHost;
IndyUDPChannel.Port := 8090;
end;
{NamedPipeServer} 7: begin
RemoteService.Channel := NamedPipeChannel;
end;
{WinMessageServer} 8: begin
RemoteService.Channel := WinMessageChannel;
end;
else
{DLLChannel}
RemoteService.Channel := DLLChannel;
end;
RemoteService.Message := BinMessage;
Result := RemoteService as IMultiChannelService;
end;
procedure TMultiChannel_ClientMainForm.GetServerTimeButtonClick(
Sender: TObject);
var
srv: IMultiChannelService;
begin
srv := GetMultiChannelService;
Log('use ' + RemoteService.Channel.Name);
Log('GetServerTime');
Log('-------------');
Log('Receiving:'#9 + DateTimeToStr(srv.GetServerTime));
Log('');
end;
procedure TMultiChannel_ClientMainForm.Log(Astr: string);
begin
CriticalSection.Enter;
try
Memo.Lines.Add(Astr);
finally
CriticalSection.Leave;
end;
end;
procedure TMultiChannel_ClientMainForm.FormCreate(Sender: TObject);
begin
CriticalSection := TCriticalSection.Create;
end;
procedure TMultiChannel_ClientMainForm.FormDestroy(Sender: TObject);
begin
CriticalSection.Free;
end;
end.