473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Where to place server code to invoke when client page closes.

Hi!

I have a new problem with this SCENARIO I already described in a previous
post:
- PBX (a private telephone exchange or switch)
- A Telephony Server Application running on computer "A" (it communicates
with the PBX via IP)
- An ASP.NET application (running on computer "A") for web clients of that
telephony server (running on computer "B", "C", etc.)

PROBLEM: When the web client closes the page (or the browser) ASP.NET should
invoke a method of the Telephony Server (DisconnectClient). This is very
important. If not, ghost clients would be living forever in the memory of
the Telephony server.
It doesn't mind if the method is invoked several minutes after closing the
browser (15 or 20 minutes as a maximum); but it has to be invoked.

I ALREADY HAVE TRIED...
to invoke it at "Session_End" in Global.asax. But at this point of the code
the Telephony-server proxy object is already "null".
Then I thought: If the object is null, code has to step through the
destructor and/or the Dispose method of it: but it doesn't.
Then I thought: I could try the "OnDispose" event of an important graphic
asp.net component of the page: Never called, either.
The "OnUnload" event: This one is called too frequently, maybe because of an
ajax timer I use in the page...
Client-side "onunload": but it has no access to server-side objects...
And, well, I have run out of ideas!

Could you please tell me where should I place this code?

Thank you very much!

Ricardo.
Nov 14 '06 #1
3 1584
"Ricardo Vazquez" <rv******@dummy.comwrote in message
news:ug**************@TK2MSFTNGP03.phx.gbl...
I ALREADY HAVE TRIED...
to invoke it at "Session_End" in Global.asax. But at this point of the
code the Telephony-server proxy object is already "null".
Why is is null? Are you setting it to null somewhere? Is the GC destroying
it because it's fallen out of sope?
PROBLEM: When the web client closes the page (or the browser) ASP.NET
should invoke a method of the Telephony Server (DisconnectClient). This is
very
How does the DisconnectClient method know which client to disconnect? Do you
pass it some sort of argument? Does each client object have some sort of
unique identifier property?

I have encountered a similar problem with a login audit table where the
Session_End needed to record the time that the logged-on user logged out. If
the user didn't log out "cleanly" i.e. by clicking the "Log out" button,
then all sorts of problems occurred when the session ended.

The solution was quite simple: when the user logged in, I persisted a unique
identifier representing the login object which I stored as a Session
variable, then amended the Session_End method to use that instead when the
session was torn down, either manually by the user logging out cleanly or by
the session timing out automatically.
Nov 14 '06 #2
"Mark Rae" <ma**@markNOSPAMrae.comescribió en el mensaje
news:uA**************@TK2MSFTNGP03.phx.gbl...
"Ricardo Vazquez" <rv******@dummy.comwrote in message
news:ug**************@TK2MSFTNGP03.phx.gbl...
Thank you very much for your interest, Mark!
Here I answer your questions:
>I ALREADY HAVE TRIED...
to invoke it at "Session_End" in Global.asax. But at this point of the
code the Telephony-server proxy object is already "null".

Why is is null? Are you setting it to null somewhere? Is the GC destroying
it because it's fallen out of sope?
The object is called "app", and here it is its creation (this is the only
point where "new Aplicacion" is called):

protected void btnEnter_Click(object sender, EventArgs e)
{
...
if (app == null)
{
app = new Aplicacion(Request.UserHostAddress,
Server.MapPath("App_Data"));
Session["app"] = app;
}
...
}

As you see, I make it a persistent Session object.
I do not set it to null anywhere.

Whereever I need it I call something like this:

Aplicacion app = Session["app"] as Aplicacion;
if (app == null)
{
return;
}

But the "if (app == null)" condition is false everywhere but in
"Session_End".

Aplicacion implements the IDisposable interface, but the "Dispose" method is
never called (I also try the Disconnect I need here):
public void Dispose()
{
if (g_cti != null && g_cti.Conectado)
{
string sClientId = ClientIdentifier;
g_cti.DisconnectClient(ref sClientId);
}
}
>PROBLEM: When the web client closes the page (or the browser) ASP.NET
should invoke a method of the Telephony Server (DisconnectClient). This
is very

How does the DisconnectClient method know which client to disconnect? Do
you pass it some sort of argument? Does each client object have some sort
of unique identifier property?
Yes. One of the Properties of "app" (instance of class Aplicacion for a
webclient) is "ClientIdentifier".

I have encountered a similar problem with a login audit table where the
Session_End needed to record the time that the logged-on user logged out.
If the user didn't log out "cleanly" i.e. by clicking the "Log out"
button, then all sorts of problems occurred when the session ended.

The solution was quite simple: when the user logged in, I persisted a
unique identifier representing the login object which I stored as a
Session variable, then amended the Session_End method to use that instead
when the session was torn down, either manually by the user logging out
cleanly or by the session timing out automatically.
When Session_End is fired, this is the code that runs:

Aplicacion app = Session["app"] as Aplicacion;
if (app != null)
{
if (app.g_cti != null && app.g_cti.Conectado)
{
string sClientId = app.ClientIdentifier;
app.g_cti.DisconnectClient(ref sClientId);
}
}

Which I think is quite similar to your solution, isn't it?
But, as I said, here app is null, so I never get this working... :-(
Any ideas on what may be happening?
Thank you very much,

Ricardo.
Nov 14 '06 #3
"Ricardo Vazquez" <rv******@dummy.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
The object is called "app", and here it is its creation (this is the only
point where "new Aplicacion" is called):
I'm presuming that 'Aplicacion' is a custom class, and not the Spanish
language way of referring to the 'Application' object...?
As you see, I make it a persistent Session object.
Hmm - I'm not entirely sure that you do...
I do not set it to null anywhere.
Maybe not, but something clearly does...If you're not explicitly disposing
it, then I can only assume that the GC is disposing it for you because it
has fallen out of scope - that's why I don't think you're are persisting it
in the Session object in the way that you think you are...
Whereever I need it I call something like this:

Aplicacion app = Session["app"] as Aplicacion;
if (app == null)
{
return;
}

But the "if (app == null)" condition is false everywhere but in
"Session_End".
Hmm - OK - so the app object is available everywhere in your app APART from
in Session_End...? Is this the same if you tear down the session manually,
or if the session times out automatically...?
Aplicacion implements the IDisposable interface, but the "Dispose" method
is never called (I also try the Disconnect I need here):
public void Dispose()
{
if (g_cti != null && g_cti.Conectado)
{
string sClientId = ClientIdentifier;
g_cti.DisconnectClient(ref sClientId);
}
}
Are you absolutely sure it's never called...? Have you set a breakpoint at
the top of the method...?
But, as I said, here app is null, so I never get this working... :-(
Any ideas on what may be happening?
Well, something somewhere is clearly disposing your app object - can you set
a watch on it and step through (F11, not F10) your web application until the
object is disposed...? This could be a bit of a chore, but I can't really
think of any other way at the moment...
Nov 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WIWA | last post by:
Hi, I want to make a UDP client server application that is conform to RFC868 (Time protocol). Both the UDP client and UDP server are in a test phase. The question is: when I add ...
12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
1
by: feng | last post by:
Hi, When user closes a browser window by clicking on the "X" button, I want the server to be noticed (either through postback or calling other ASP pages, etc.) and perform some task...
4
by: Piotr Strycharz | last post by:
Hi all I do have a problem. How can I transfer user to another server using POST. The problem is that Server.Transfer (preserves form data) works just in current server. Response.Redirect -...
22
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said...
4
by: rs | last post by:
how I the client tell the server that the socket is closed? or this there an even that informs the server that the clients socket is close? Oh, I am using vb.net 2003 Thanks
9
by: diffuser78 | last post by:
My server.py looks like this ---------------------------------------------CODE---------------------------------- #!/usr/bin/env python import socket import sys import os s =...
2
AnuSumesh
by: AnuSumesh | last post by:
Hi I m new to ASP 'n' this forum also. I m writing one code to invoke remote desktop service for given IP address. For that i m using mstsc.exe file to invoke RDP. I have a no of links to be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.