UserRecord
Unit
AstaTypes
The AstaServerSocket maintains a UserList of type TUsers.
The Tusers is a List of Pascal Record defined as
UserRecord = packed record
UserName: string[255];
AppName: string[255];
ConnectTime: TDateTime;
FClientSocket: TCustomWinSocket;
FClientMessage: string;
FMessageStack: TAstaMessageStack;
FStringLine: TAstaStringLine;
FParamList:TAstaParamList;
FMaxAsyncPool:Integer;
end;
An Entry is created in the UserList when a remote client connects to the server. At connect time there will be a UserRecord but no UserName or AppName as that flows in from the LoginEvents (OnClientLogin,OnClientDBLogin)
The OnUserListChange is available to track changes to the userRecord AstaServerSocket.OnUserListChange
The OnUserList change used to come in with an IsNew:Boolean but this did not accurately reflect what happens on a server.
A remote client first connects to a server and then goes through a login process and then can be disconnected.
So the new AState:TUserRecordState more accurately reflects the action of the ClientSocket;
Here is an example of the way ASTA 2.3X and higher servers update the UserDataSet that is on Asta demo servers. Note: clients needs to come in with login info for this to accurately reflect all the states.
TUserRecordState is defined in AstaTypes.pas
procedure TForm1.UpdateUserDataSet(Address: string; AState:TuserRecordState);
begin
with UserDataSet do begin
Append;
FieldbyName('Address').AsString := Address;
case Astate of
tuConnect :FieldbyName('Activity').AsString := 'Connected';
tuDisconnect :FieldbyName('Activity').AsString := 'Disconnected';
tuLogin :FieldbyName('Activity').AsString := 'Login';
end;
FieldByName('Date').AsDATeTime := Now;
Post;
end;
end;
procedure TForm1.AstaServerSocket1UserListchange(Sender: TObject;
Socket: TCustomWinSocket; Astate: TUserRecordState);
begin
UpdateUserDataSet(Socket.RemoteAddress, Astate);
end;