clientFrm.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:2k
- unit clientFrm;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, MConnect, ObjBrkr, DB, DBClient, SConnect, ExtCtrls, DBCtrls,
- Grids, DBGrids, StdCtrls, Buttons;
- type
- TfrmClient = class(TForm)
- SocketConnection1: TSocketConnection;
- ClientDataSet1: TClientDataSet;
- DataSource1: TDataSource;
- SimpleObjectBroker1: TSimpleObjectBroker;
- Panel1: TPanel;
- Panel2: TPanel;
- DBGrid1: TDBGrid;
- DBNavigator1: TDBNavigator;
- edtAppServerName: TEdit;
- edtAppServerTime: TEdit;
- btnGetServerInfo: TBitBtn;
- btnClear: TBitBtn;
- Label1: TLabel;
- Label2: TLabel;
- procedure btnGetServerInfoClick(Sender: TObject);
- procedure btnClearClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmClient: TfrmClient;
- implementation
- {$R *.dfm}
- procedure TfrmClient.btnGetServerInfoClick(Sender: TObject);
- var
- vServerName: Variant;
- vServerTime: Variant;
- begin
- try
- //调用服务器端提供的GetServerName方法和GetServerTime方法
- socketConnection1.AppServer.GetServerName(vServerName);
- socketConnection1.AppServer.GetServerTime(vServerTime);
- edtAppServerName.Text := vServerName;
- edtAppServerTime.Text := vServerTime;
- //调用失败,就用SimpleObjectBroker1组件,去连接别的服务器,以获得服务
- except
- on exception do
- begin
- SimpleObjectBroker1.SetConnectStatus(SocketConnection1.Host, false);
- SocketConnection1.Connected := False;
- SocketConnection1.Host := simpleObjectBroker1.GetComputerForProgID('Server.CorrectServer');
- socketConnection1.Connected := True;
- btnGetServerInfoClick(Sender);
- end;
- end;
- end;
- procedure TfrmClient.btnClearClick(Sender: TObject);
- begin
- edtAppServerName.Text :='';
- edtAppServerTime.Text :='';
- end;
- end.