Display Text Instead of an Image for Online/Offline

How can just text be displayed for webchat online or offline without using an image?

You will probably need to modify webchat source and compile your own version.

We are not interested in modifying the source code if we can help it, and don’t have the chops to do it anyway. What we do instead is use an external script as a hack to get at the workgroup presence information.

If you notice, the same URL on your openfire server calls either the ‘online’ or ‘offline’ image, and not only are they different images, they are different sizes. So the script hits that URL, checks the size of the image, and decides if the workgroup is online or offline.

The image is available from the URL:

http://yourserver/webchat/live?action=isAvailable&workgroup=whatever@workgroup.y ourserver

The default ‘online’ image is 1329 bytes and the default ‘offline’ image is 1513 bytes. If you needed to, you could set these images to 1 and 2 bytes. You can also cache the result if you don’t want to check every page load.

The PHP code goes something like this, but you could apply this technique however you want.

$url = "http://yourserver/webchat/live?action=isAvailable&workgroup=whatever@workgroup.yourserver";
  $online_size = 1329;
  $ch =curl_init($url);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  curl_setopt($ch, CURLOPT_CURLOPT_TIMEOUT, 60);
  $page = curl_exec($ch);
  $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  $bytes = curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
  curl_close($ch);   if ($response_code == 200 && $bytes == $online_size) {
    $status = 1;
  else {
    $status = 0;

I would love to know if anyone has any suggestions for making this more efficient.

1 Like

It is nice that you have shared your work around script. You can also create a doc and put these instructions in there. If you do, then drop me a link to that doc, i will add it to the list of Fastpath tutorials and tips, or you can add it yourself http://community.igniterealtime.org/docs/DOC-1876

Ok, I made one at http://community.igniterealtime.org/docs/DOC-2128. I’m not sure how to add this to the main document.

I tried to list the things we’re doing with it so far, as well as the potential to meet Stretchem’s need. An official and efficient API would be nice of course. I would love to be able to get presence-in-workgroup data. FastPath’s strength really is that it is built on OpenFire, so I’m very happy with the functionality and stability we get, but there is always more we could be doing.

Thanks. Added it to the main document.