/*
* Guacamole - Clientless Remote Desktop
* Copyright (C) 2010 Michael Jumper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
/**
* Main Guacamole web service namespace.
* @namespace
*/
var GuacamoleService = GuacamoleService || {};
/**
* An arbitrary Guacamole connection, consisting of an ID/protocol pair.
*
* @constructor
* @param {String} protocol The protocol used by this connection.
* @param {String} id The ID associated with this connection.
*/
GuacamoleService.Connection = function(protocol, id) {
/**
* Reference to this connection.
*/
var guac_connection = this;
/**
* The protocol associated with this connection.
*/
this.protocol = protocol;
/**
* The ID associated with this connection.
*/
this.id = id;
/**
* All parameters associated with this connection, if available.
*/
this.parameters = {};
/**
* An array of GuacamoleService.Connection.Record listing the usage
* history of this connection.
*/
this.history = [];
/**
* Returns the number of active users of this connection (which may be
* multiple instances under the same user) by walking the history records.
*
* @return {Number} The number of active users of this connection.
*/
this.currentUsage = function() {
// Number of users of this connection
var usage = 0;
// Walk history counting active entries
for (var i=0; i