ASTA的学习

来源:互联网 发布:c语言课程设计案例 编辑:程序博客网 时间:2024/05/29 06:49

程序Asta3ADOServer学习

程序单元里面的AstaServiceName:=AstaDefaultServiceName; 两个都是AstaServiceUtils.pas里面的东西,不清楚是做什么用的。

调试发现if Installing or StartAstaService then 

                begin

                       ......

                end

                else

                begin

                     Forms.Application.ShowMainForm := False;
                     Forms.Application.Initialize;
                     Forms.Application.CreateForm(TAstaADOServiceForm, AstaServiceForm);//TAstaADOServiceForm是自定义的类,AstaServiceForm是系统的,

                                                                                                                                                            //TAstaADOServiceForm继承自TAstaServiceForm
                     AstaServiceForm.Initialize(False); //不清楚,这个起什么作用
                     Forms.Application.Run;

                end;

走else之后的语句块;


function GetThePCsIPAddress: string;
var
  WSAData: TWSAData;
  HostName, Address: string;
  HostEnt: PHostEnt;
begin
  { no error checking...}
  WSAStartup($0101,WSAData);//(版本号,TWSAData类型返回WinSock库的一些信息,如版本号,监听队列的大小,你能创建的最多的socket数目)
  SetLength(HostName, 255);
  gethostname(PChar(HostName), 255);//获得计算机名
  SetLength(HostName, StrLen(PChar(HostName)));
  HostEnt := gethostbyname(PChar(HostName));//获得IP地址
  with HostEnt^ do
    Address := Format('%d.%d.%d.%d', [Byte(h_addr^[0]), Byte(h_addr^[1]),
      Byte(h_addr^[2]), Byte(h_addr^[3])]);
  WSACleanup;//要执行WSAStartup函数初始化SOCK,结束后要执行WSACleanup
  Result := Address;
end;


{$hints off}
function TAstaServiceForm.UseRemoteControl: Boolean;
begin
{$IFDEF AstaRemoteControl}
  result := True;
  {$else}
  result := False;
  {$ENDIF}
end;
{$hints on}


继承自TAstaService的类必须要实现log方法。因为procedure Log(Msg: string); virtual; abstract;


有两个dm:SocketDM和dm

 

ServerSocket.Address := AstaADOServiceForm.IpAddressEdit.Text;
---没发现ServerSocket在属性面板里面有这个属性

ServerSocket.Port := StrToIntDef(AstaADOServiceForm.PortEdit.Text, 9000);---设置默认端口


处理application的OnException事件
  public
    { Public declarations }
    procedure AstaException(Sender: TObject; E: Exception);
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.AstaException(Sender: TObject; E: Exception);
begin
{}
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  application.OnException := AstaException;
  astaserversocket1.active := True;
end;


Authenticate---认证  AstaServerSocket1ClientAuthenticate客户端认证
encryption---加密

Sessions--会话

THreadingModel--线程模式

AstaServerSocket1ShowServerMessage--显示服务器信息;

procedure LogServerActivity(LogItems: TAstaLogItems; S: TcustomWinSocket; const Msg: string);---登陆服务器活动;

property LogEvent: TServerLogEvent; --服务器登陆事件

procedure RecordServerActivity(S: TCustomWinSocket; Msg: string);--记录服务器活动(如果你在 TAstaServerSocket 的OnShowServerMessage 事件里面写了代码,那么RecordServerActivity 过程将调用这个代码. 这个方法一般是被内部使用来显示线程信息和其他数据库的活动情况。)