# Who is Online

**URL:** <https://forum.servoy.com/t/who-is-online/8993>\
**Category:** Classic Servoy\
**Created:** [April 9, 2008, 12:18pm UTC](https://forum.servoy.com/t/who-is-online/8993 "2008-04-09T12:18:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Briggsy-is-back](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@Briggsy-is-back](https://forum.servoy.com/u/Briggsy-is-back)\
**Post date:** [April 9, 2008, 12:18pm UTC](https://forum.servoy.com/t/who-is-online/8993/1 "2008-04-09T12:18:54Z")

</div>

My solution requires that I describe “Who is Online” similar to the Servoy Forum Index.  
I can get a value list of all registered users, thanks to “The Servoy Guy”, but how do I know who is online now?

---

<div class="post-metadata">

**Author:** ![sbutler](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/sbutler/32/4393_2.png) [@sbutler](https://forum.servoy.com/u/sbutler)\
**Post date:** [April 10, 2008, 3:02pm UTC](https://forum.servoy.com/t/who-is-online/8993/2 "2008-04-10T15:02:47Z")

</div>

I assume your referring to [http://www.servoyguy.com/code\_repositor … rvoy\_users](http://www.servoyguy.com/code_repository/specialty/get_a_value_list_of_all_servoy_users)

Currently, there isn’t a way to know which users are online, but you can use this…

//run on startup for each client  
application.addClientInfo(“someUniqueIdentifier”)

//then get the number of clients with that info  
application.getClientCountForInfo(“someUniqueIdentifier”)

However, that only gets you the count, not a direct handle to the clients. So you can’t get information about the connected clients, like what is their username, user groups, etc. I’ve been working on a plugin for this which may be released in a few weeks.

---

<div class="post-metadata">

**Author:** ![Briggsy-is-back](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@Briggsy-is-back](https://forum.servoy.com/u/Briggsy-is-back)\
**Post date:** [April 11, 2008, 11:22am UTC](https://forum.servoy.com/t/who-is-online/8993/3 "2008-04-11T11:22:49Z")

</div>

Thanks Scott, I look forward to your next reply.

---

<div class="post-metadata">

**Author:** ![Briggsy-is-back](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@Briggsy-is-back](https://forum.servoy.com/u/Briggsy-is-back)\
**Post date:** [September 29, 2009, 7:33pm UTC](https://forum.servoy.com/t/who-is-online/8993/4 "2009-09-29T19:33:13Z")

</div>

The main reason I would like to know this is…  
Re: 4.1  
If I sell somebody 10 Servoy licenses I would like them to know when it is time to buy more.  
It is real hard for me to sell more licenses when they don’t have a handle on how many they are actualy using.  
I will take any suggestions.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [September 29, 2009, 7:44pm UTC](https://forum.servoy.com/t/who-is-online/8993/5 "2009-09-29T19:44:16Z")

</div>

Hi Briggsy,

If you want to know the used up licenses at any time then you can use the technique described by Scott.  
I use it myself in a SaaS situation to make sure a client doesn’t use more than his/hers paid licenses.

---

<div class="post-metadata">

**Author:** ![Briggsy-is-back](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@Briggsy-is-back](https://forum.servoy.com/u/Briggsy-is-back)\
**Post date:** [September 29, 2009, 8:00pm UTC](https://forum.servoy.com/t/who-is-online/8993/6 "2009-09-29T20:00:52Z")

</div>

Thanks Robert  
How could I put this into a progress bar showing green to red!  
Do you know?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [September 29, 2009, 8:22pm UTC](https://forum.servoy.com/t/who-is-online/8993/7 "2009-09-29T20:22:33Z")

</div>

Hi Briggsy,

Well at startup of a solution you need to set the unique identifier like Scott mentioned.  
After that you can use something like this method to set a form global that is used as dataprovider on a field (using display type HTML\_AREA).

```auto
function setUsedClientsHTML() {
    var _sHTML = '<html><table width="100%" cellpadding="0" cellspacing="0"><tr>',
        _nMax = 10,
        _nCurrent = application.getClientCountForInfo("someUniqueIdentifier"),
        _nThreshold = 8,
        _nPercUsed = (_nMax/100)*_nCurrent;

    // the progressbar
    _sHTML += "<td width="' + _nPercUsed + '%" bgcolor="';
    if ( _nCurrent >= _nThreshold ) {
        _sHTML += "#ff0000"; // red
    } else {
        _sHTML += "#00ff00"; // green
    }
    '"></td>'; 
    _sHTML += "<td width="' + (100-_nPercUsed) + '%"></td>'; // what's left
    
    forms.yourForm.yourFormGlobal = _sHTML + '</tr></table></html>';
}

```

Okay, this is untested code but you get the idea.  
Now how you will trigger this method is up to you. You can do it on an onShow, or via a scheduler process. It all depends on how much you want this to refresh.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Briggsy-is-back](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@Briggsy-is-back](https://forum.servoy.com/u/Briggsy-is-back)\
**Post date:** [September 29, 2009, 8:25pm UTC](https://forum.servoy.com/t/who-is-online/8993/8 "2009-09-29T20:25:58Z")

</div>

That’s Awsome dude!  
Thank you very much, I will refine and post code.

---

<div class="post-metadata">

**Author:** ![Briggsy-is-back](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@Briggsy-is-back](https://forum.servoy.com/u/Briggsy-is-back)\
**Post date:** [September 29, 2009, 10:39pm UTC](https://forum.servoy.com/t/who-is-online/8993/9 "2009-09-29T22:39:53Z")

</div>

Assuming every client is shut down each day.  
Solution on open method:

```auto
	var vtoday = plugins.DateUtils.DateTime();
	vtoday = vtoday.day
	//run on startup for each client 
	application.addClientInfo(vtoday) 

	//then get the number of clients with that info 
	globals.number_online = application.getClientCountForInfo(vtoday)

```

I created the folowing Form Field

to look like this…

Create globals.number\_online\_html

```auto
function license_count_html()
{
    var sHTML = '<html> <body> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="',
        nMax = globals._number_of_licenses, // Maximum number of licenses
        nCurrent = globals.number_online,
        nYellowThreshold = .75,       
        nRedThreshold = .85,
        nPercUsed = nCurrent / nMax;
		
    	// the progressbar
   		sHTML += nPercUsed * 100 + '%" bgcolor="';
    if ( nPercUsed >= nRedThreshold ) 
    {
         sHTML += '#ff0000'; // red
    }
    else if ( nPercUsed >= nYellowThreshold )
    {
        sHTML += '#FFCC00'; // yellow
    }
    else
    {
        sHTML += '#006600'; // green
    }
    
    sHTML += '"></td>'; 
    sHTML += '<td width="' + (100-nPercUsed*100) + '%"></td>'; // what's left
    globals.number_online_html = sHTML + '</tr></table></html>';
}

```

---

<div class="post-metadata">

**Author:** ![Briggsy-is-back](https://avatars.discourse-cdn.com/v4/letter/b/45deac/32.png) [@Briggsy-is-back](https://forum.servoy.com/u/Briggsy-is-back)\
**Post date:** [September 29, 2009, 10:41pm UTC](https://forum.servoy.com/t/who-is-online/8993/10 "2009-09-29T22:41:08Z")

</div>

How do you determine how many licenses are available with code please?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [September 29, 2009, 10:50pm UTC](https://forum.servoy.com/t/who-is-online/8993/11 "2009-09-29T22:50:05Z")

</div>

> Briggsy-is-back!:  
> How do you determine how many licenses are available with code please?

Available on the server ? As far as I know you can’t.  
I guess you can file a feature request for this, with [Servoy](http://www.servoy.com/s) or with Patrick for in his commercial [UserManager plugin](http://www.servoy-plugins.de/plugins/usermanager/usermanager-plugin.html).
