Read the comment in server execute
Kod: Tümünü seç
uses
Idsync;
....................
....................
TConnection = class(TObject)
Private
public
Name: String;
Connected: TDateTime;
UniqueID: DWORD;
Thread: Pointer;
procedure AddToListView;
end;
procedure TConnection.AddToListView;
var
LName: string;
LIP: string;
LConnected: TDateTime;
LUniqueID: Dword;
Item: TListItem;
begin
LName := Self.Name;
LConnected := Self.Connected;
LUniqueID := Self.UniqueID;
begin
if (fMain = nil) or (fMain.lwConnections = nil) then Exit;
Item := fMain.lwConnections.Items.Add;
try
Item.Data := Self;
Item.Caption := LName;
Item.SubItems.Add(FormatDateTime('hh:mm:ss', LConnected));
Item.SubItems.Add(IntToStr(LUniqueID));
except
Item.Delete;
raise;
end;
end;
end;
procedure TfMain.TCPServerExecute(AContext: TIdContext);
var
Connection: TConnection;
begin
Connection := Pointer(AContext.Data);
if Command = 'LOGIN' then
begin
if Password <> Params[1] then
AContext.Connection.Socket.WriteLn('INVALIDPASSWORD')
else
end;
if Command = 'TAKEMYINFO' then //login ok, add to listview
begin
Connection.Name := Params[1];
Connections.Add(Connection);
TIdNotify.NotifyMethod(Connection.AddToListView);// is this a right way to synchronize ?
end;
end;