How can I detect when the server has disconnected a client connection?

I have a client application that is connecting to a DA server using IpSuperTcpClientChannel. Is there a way to detect when the server has disconnected the client following the timeout specified in MemorySessionManager.Timeout.

I’ve tried checking the following:
ClientChannel.Active - this is always true.
ClientChannel.Connected - this is always true.
ClientChannel.OnDisconnected - this never fires.

This is a .net client connecting to a .net server, I’m using Oxygene in both.

Thanks for your help

Hi,

You have mixed 2 different situations:

  • expired session
  • channel connection

when session is expired, it just clears current session and have no influence to channel.

when client accesses to expired session, server-side fires SessionNotFoundException exception.

Client-side can handle this exception automatically if ClientChannel.OnLoginNeeded event is assigned.

our templates suggest to use this implementation for this event:

method DataModule.ClientChannel_OnLoginNeeded(sender: Object; e: LoginNeededEventArgs);
begin
  // Performing login
  if self.LogOn(Properties.Settings.Default.UserId, Properties.Settings.Default.Password) then begin
    e.Retry := true;
    e.LoginSuccessful := true;
    exit;
  end;

  var lUserId: String;
  var lPassword: String;

  using lLogOnForm: LogOnForm := new LogOnForm() do begin
    if lLogOnForm.ShowDialog() <> DialogResult.OK then begin
      MessageBox.Show('Login canceled');
      exit;
    end;

    lUserId := lLogOnForm.UserId;
    lPassword := lLogOnForm.Password;
  end;

  if self.LogOn(lUserId, lPassword) then begin
    e.Retry := true;
    e.LoginSuccessful := true;
  end
  else begin
    MessageBox.Show('Login failed');
   end;
end;

You can call [empty] server’s method from client in loop if you want to have persistent session. for example, call every 13 min if SessionManager.Timeout is set to 15 min

Hi Evgeny,
Thanks for this response, it should allow me to do what I need.
Thaks for your help