Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Indy TidIPWatch - onstatuschange ? (https://www.delphipraxis.net/182675-indy-tidipwatch-onstatuschange.html)

oakley 9. Nov 2014 22:32

Indy TidIPWatch - onstatuschange ?
 
Hallo,

ich möchte gerne mit der Indy Komponente TidIPWatch meine lokale IP bestimmen.
Ich mache das im Event onstatuschange und das funktioniert genau ein mal.

Wenn sich meine IP ändert (ich habe mal testweise meine statische IP verändert) wird dieser Event aber nicht durchlaufen.

Liegt das evtl. an der Indykomponente oder ist das falsche Event?

OnStatus wird allerdings auch nicht abgefeuert.

Ich nutze XE6 mit Indy 10.6.0.5122.

Gruß

Mirko

mjustin 10. Nov 2014 07:56

AW: Indy TidIPWatch - onstatuschange ?
 
Zitat:

Zitat von oakley (Beitrag 1279241)
Liegt das evtl. an der Indykomponente oder ist das falsche Event?

Ist es denn die "richtige" Komponente? Als Beschreibung habe ich dieses gefunden:

Zitat:

TIdIPWatch - dient dazu, den Online-Status und die aktuelle IP-Adresse festzustellen.
Und im Code ist die Bedingung für den Aufruf von OnStatusChange:

Delphi-Quellcode:
    if ((WasOnline) and (not FIsOnline)) or ((not WasOnline) and (FIsOnline)) then
    begin
      if (not IsDesignTime) and Assigned(FOnStatusChanged) then
      begin
        FOnStatusChanged(Self);
      end;
    end;
Ein IP-Adressenwechsel wird anscheinend nicht als Kriterium für das Event verwendet.

oakley 10. Nov 2014 14:25

AW: Indy TidIPWatch - onstatuschange ?
 
Ok verstehe... so wie das aussieht ist der Wechsel von online zu offline das und umgekehrt das Kriterium.

Dann ist wirklich die Frage ob es die richtige Komponente ist. Vielleicht besser AddrMon. Ich probiere das mal.

Danke für Deine Hilfe !

Viele Grüße

Mirko

himitsu 10. Nov 2014 16:54

AW: Indy TidIPWatch - onstatuschange ?
 
Zitat:

Description
TIdIPWatch determines Online status, returns current IP address, and (optionally) keeps history of IP addresses issued to the computer using the class instance.
Von der Beschreibung her klingt TidIPWatch eigentlich richtig. :gruebel:

OnStatus und StatusChanged werden also nur am Anfang ausglöst und danach nicht mehr?
Auch nicht, wenn du mal etwas länger wartest?


PS: Noch bissl binäre Mathematik:
Delphi-Quellcode:
if (WasOnline and not FIsOnline) or (not WasOnline and FIsOnline) then

lässt sich arithmetisch in eine XOR umwandeln (exclusive or)
Delphi-Quellcode:
if WasOnline xor FIsOnline then

oder logisch in
Delphi-Quellcode:
if WasOnline <> FIsOnline then


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:39 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz