If a user is chatting in the Instant Messenger he/she is unlikely not surfing through your community. Thus you will not know if the user is still online.
You can pass a url (own_url) to the implementation code of stickapps. This Url will be called once the IM ist opened or in an interval if you also pass the parameter own_url_interval (interval in seconds). In this url you can now keep the user presence since it will only be called if the Instant Messenger is opened.
Example implementation code. Will call the URL http://www.your-domain.com/keep_online.php every 60 seconds
<script type="text/javascript"> var TOKSTA_CONFIG = { app_id: "your-application-id", user_id: "the-user-id", user_hash: "the-user-hash", user_data: "the-user-data", generated: "current-unix-timestamp", //adjustments needed own_url: "http://www.your-domain.com/keep_online.php", own_url: 60 //------ }; </script> <script src="http://embed.toksta.com/embed/toksta.js" type="text/javascript"></script>