/cfcgntp

Coldfusion CFC wrapping libgrowl

Primary LanguageColdFusionApache License 2.0Apache-2.0

README.md

cfcgntp

Hi! This is a little simple CFC (ColdFusion component/object) that enables sending notifications to a Growl/GNTP host. This should work under both Railo and Adobe ColdFusion and is programmed in cfscript CFML. The object works by calling the libgrowl jar, and is essentially a wrapper.

Basically it lets you send real-time alerts that pop-up on the desktop of the specified computer.

The cfc has been designed to be used as a singleton, i.e. instantiated in the Application scope or in a FW1 controller - scopes that exists for the lifetime of the application.

Why?

What would you use this for?

  • Intranet situations
  • Server/service monitoring for real time alerts
  • Debugging
  • Administrative interfaces

Installation

  1. Clone this repository somewhere accessible as a CFC, under your web root or in a Custom Tag path etc.
  2. Download and build the libgrowl https://github.com/sbower/libgrowl java library and put that in a path where your cfml-engine can access the library, that would likely be a lib folder in the servlet container or similar.
  3. Now you can create an instance of the cfc in your files, and call the notify() method to send messages (might work with http://sourceforge.net/projects/libgrowl/ as well, but I switched out the libraries now, the sourceforge one doesn't allow for network notifications)

Usage

First initialize and instantiate the object:

gntp = new gntp(
    host='localhost',
    application='MyApplication',
    icon='https://raw.githubusercontent.com/fraxen/cfcgntp/master/gntp.png'
);
gntp.notify('Title of message', 'A little test message');
gntp.notify('Da title', 'Another message');

All arguments to init() are optional:

  • hostname, hostname of the growl server defaults to localhost
  • pasword, for network notifications
  • Application name, the name of the application defaults to APPLICATION.ApplicationName
  • icon, optional url or file reference to a icon image file defaults to a default icon
  • port, defaults to 23053

For notify() the title and message arguments are mandatory, the rest are optional:

  • title, title of the notification required
  • message, message body required
  • icon, optional url or file reference to an icon image file defaults to icon chosen at init
  • priority, optional priority number, higher is more important, usually between -2 and 2 defaults to 0
  • sticky, boolean - defines if the notification should stick around until manually dismissed defaults to false

Notes

There is currently no exception and error handling, but I guess errors from libgrowl should propagate. Icons - I haven't gotten it to work with the new library, for anything but URL:s to icons, it might need some tweaking...

License

This repository and all contents are licensed under the Apache 2 license, see the license file for full details.