function TZConnection.PingServer: Boolean;
var
LastState : boolean;
begin
// Check connection status
LastState := GetConnected;
if FConnection <> nil then
begin
Result := (FConnection.PingServer=0);
// Connection now is false but was true
if (not Result) and (LastState) then
// Generate OnDisconnect event
SetConnected(Result);
end
else
// Connection now is false but was true
if LastState then
SetConnected(false);
end;
ZConnection.PingServer
Moderators: gto, cipto_kh, EgonHugeist, mdaems
Sorry about explanation .. basically open ..\src\component\ZConnection.pas
and substitute
function TZConnection.PingServer: Boolean;
with the one posted.
How it works ... when PingServer is called it verify if Connection was created or not. Then check if connection is true or false. If it is false and Connected is true then raise OnBeforeDisconnect and OnAfterDisconnect events (by this way Connected is set to false).
Tested with Postgres 8.3.6
and substitute
function TZConnection.PingServer: Boolean;
with the one posted.
How it works ... when PingServer is called it verify if Connection was created or not. Then check if connection is true or false. If it is false and Connected is true then raise OnBeforeDisconnect and OnAfterDisconnect events (by this way Connected is set to false).
Tested with Postgres 8.3.6
This implementation solve 2 problems:
1. if Connection = nil (i.e. client never connected to the server) and pingserver is called an exception is raised.
2. If Connected = true but ping returns false, connected stay true .. I think would be better if Connected is set to false and raised OnAfterDisconnect and OnBeforeDisconnect events. So Connected property is set properly
About the dataset I've never checked, so tomorrow I'll do.
1. if Connection = nil (i.e. client never connected to the server) and pingserver is called an exception is raised.
2. If Connected = true but ping returns false, connected stay true .. I think would be better if Connected is set to false and raised OnAfterDisconnect and OnBeforeDisconnect events. So Connected property is set properly
About the dataset I've never checked, so tomorrow I'll do.
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
seawolf,
Shouldn't Ping and PingServer be synonyms?
Seems to me the original versions didn't have different behaviour. When we aply your patch they are different again, but is there still a use case for the old approach?
Always talking about Zeoslib 7. I don't want a behavioral change in 6.6.
Mark
Update : SVN rev. 615
Shouldn't Ping and PingServer be synonyms?
Seems to me the original versions didn't have different behaviour. When we aply your patch they are different again, but is there still a use case for the old approach?
Always talking about Zeoslib 7. I don't want a behavioral change in 6.6.
Mark
Update : SVN rev. 615