Web Client Shutdown

I need a way to detect if the webclient has shutdown.
Meaning a player is playing the game, then quits the browser, the client takes a little time to shutdown, so I want to have a method that can send my server a message telling me that he just closed out of the game (closing out of the game rather)

I assume there is a deinitialize somewhere, how do I detect and send a message prior to it finishing or when it is called?

http://unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnApplicationQuit.html

Can I directly change this things behavior so that it calls another user made method prior to it doing its work?

Meaning, I still want it to do its work, but I want to call own method that does something prior to it performing its task?

In OnApplicationQuit you can do whatever you like. You can also have many of these functions implemented in multiple scripts - they all will be called.

So I create a new script file, call it whatever, and in that place

OnApplicationQuit()
{

// do something
}

Then just attach that to the object / player or whatever.

The following doesn’t work:

using UnityEngine;
using System.Collections;

public class DisplayMessage : MonoBehaviour {

	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
	}
	
	void OnApplicationQuit () {
	}
}

When attempting to attach to anything it says:

Can’t Add Script
Can’t add script behaviour DisplayMessage. The
script needs to derive from MonoBehaviour!

But its base IS MonoBehaviour…

Well, I don’t know if this was the proper “fix” but I decided to just do a “rebuild assets”, took like 15 minutes then after it reloaded my game, I got the method to work. Now back to doing some cool script testing.
Oddly, my current scene is about 37 megs, only 1 music file attached, a bare bone castle, a few houses in the village, couple dozen trees, some weapons with scripts attached to them.

I really need to figure out how to attach the camera to the player object, enable collision on everything etc. Guess that will come in time, having more fun with the scripts at the moment.

Ok, I am confused;

	void OnApplicationQuit () {
		//Application.OpenURL ("http://unity3d.com/");
		Application.ExternalCall ("DisplayMessage", "Thank you for trying Faith!!");
	}

If I have it do the OpenURL, it opens the url on exit, but if I do the externalcall, it does it on game load.

Can someone please explain this to me…

I am also facing the same problem that the web site cannot check if the unity application is quitted or not… :cry:

is there any method to let the web page know when it quits?