Need to close down application (Video Conferencing) after set Time (in GB used)
I tried with below string, but do not work. When I added it, I can not
login to my application (Video Conferencing) , when removed I can login
again.
Can any see the mistake, thanks!


var initTime = 5000; //milliseconds used to check the bandwidth total.
var cap = 26843545600; //roughly 25gb bandwidth cap limit.

application.onAppStart = function()
{
soDirBand = SharedObject.get("DirectoryBandwidth", true);
this.startInit();
if (totalBytes >= cap)
{
this.shutdown();
};
};

application.onConnect = function ( newClient )
{
this.acceptConnection(newClient);
};

application.startInit = function ()
{
this.bwInit = setInterval(this, "checkBand", initTime)
};

application.checkBand = function()
{
stats = this.getStats();
totalBytes = stats.bytes_in + stats.bytes_out
trace ("Total bytes: "+ soDirBand.getProperty("totalBand"));
if (totalBytes >= cap)
{
this.shutdown();
};
};

application.onDisconnect = function (newClient)
{
this.upDateUsage();
for (i=0; i < application.clients.length; i++){
application.disconnect(application.clients);
}
};

application.onAppStop = function ()
{
clearInterval(this.bwInit);
this.upDateUsage();
trace(soDirBand.getProperty("totalBand"));
};

application.upDateUsage = function ()
{
soDirBand.setProperty("totalBand", totalBytes)
};