NetTalk is great for building browser based apps, but we still will work on a lot of Win32 based apps here at my company, and have found a way to incorporate a lot of NetTalk based features to make our apps run better.
Because I do a lot of development work on Mac OS X as well, I have become somewhat used to the nifty 'Growl' notification engine on that platform - whereby many different apps can post system wide notifications in a beautiful, non intrusive way.
Imagine my surprise and delight when I discovered that there was a Growl implementation for Windows as well. http://www.growlforwindows.com/gfw/
To summarise - Growl is a totally customisable system 'alert' window. The alert windows can be shaped to look like pretty much anything you want, and they can slowly morph into view discreetly and then fade out again. They can even be made sticky, and will neatly cascade for you if you don't respond to them immediately. The system even keeps a log of all old messages so you can go back and audit them later. You can even have icons and images in the notifications and even incorporate callbacks so that users can take action by clicking on the notification window.
We have switched to using Growl for alert messages on nearly all our apps now. Our users love it as they are not as intrusive as a normal app message, yet they still catch their attention.
As an example - we have an app we designed for a Pawn/Loan shop. Whenever they go to add a new pawn contract for an existing customer, and the customer has any outstanding contracts that are overdue, we flash up a Growl notice about the overdues. This doesn't actually interrupt their workflow while they are entering a contract at all, but they don't miss the little box that fades in and fades out at the top of the screen while they are working.
How did we integrate Growl? Well, really just by using the NetTalk WebClient template. It is that easy. I have included a small test app with this post that you can explore.
The first thing you have to do is to download and install Growl For Windows from
http://www.growlforwindows.com/gfw/. This is a once only step on each PC that you want Growl notifications on.
Then in your app, you really need two procedures. One to REGISTER your app with Growl, and one to SEND the Growl notifications themselves.
Growl uses a proprietary GNTP protocol on port 23053. It is really a slightly customised HTTP protocol. The actual code to register your app is as follows:
! Send the Registration
Window{PROP:Hide} = 1
LOC:Packet = 'GNTP/1.0 REGISTER NONE<13,10>'
LOC:Packet = Clip(LOC:Packet) & 'Application-Name: ' & Clip(pAppName) & '<13,10>'
If Clip(pAppIcon) <> '' ! If the icon was not omitted, add it
LOC:Packet = Clip(LOC:Packet) & 'Application-Icon: ' & Clip(pAppIcon) & '<13,10>'
End
LOC:Packet = Clip(LOC:Packet) & 'Notifications-Count: 1<13,10>'
! Blank line
LOC:Packet = Clip(LOC:Packet) & '<13,10>'
LOC:Packet = Clip(LOC:Packet) & 'Notification-Name: General Notification<13,10>'
LOC:Packet = Clip(LOC:Packet) & 'Notification-Enabled: True<13,10>'
LOC:Packet = Clip(LOC:Packet) & '<13,10,13,10>'
GROWL:ApplicationName = Clip(pAppName)
ThisNetGrowlRegister.Init()
ThisNetGrowlRegister.AsyncOpenUse = 1
ThisNetGrowlRegister.AsyncOpenTimeOut = 1000 ! 10 Seconds
ThisNetGrowlRegister.InActiveTimeout = 2000 ! 20 Seconds
ThisNetGrowlRegister.Open('127.0.0.1', 23053)
And for sending a notification, it is as easy as:
! Send the Notification
Window{PROP:Hide} = 1
LOC:Packet = 'GNTP/1.0 NOTIFY NONE<13,10>'
LOC:Packet = Clip(LOC:Packet) & 'Application-Name: ' & Clip(GROWL:ApplicationName) & '<13,10>'
LOC:Packet = Clip(LOC:Packet) & 'Notification-Name: General Notification<13,10>'
LOC:Packet = Clip(LOC:Packet) & 'Notification-Title: ' & Clip(pNotificationTitle) & '<13,10>'
LOC:Packet = Clip(LOC:Packet) & 'Notification-Text: ' & Clip(pNotificationMessage) & '<13,10>'
! Check if sticky flag omitted
LOC:Packet = Clip(LOC:Packet) & 'Notification-Sticky: ' & Choose(pNotificationSticky, 'True', 'False') & '<13,10>'
If Clip(pNotificationIcon) <> '' ! If the icon was not omitted, add it
LOC:Packet = Clip(LOC:Packet) & 'Notification-Icon: ' & Clip(pNotificationIcon) & '<13,10>'
End
LOC:Packet = Clip(LOC:Packet) & '<13,10,13,10>'
ThisNetGrowlNotify.Init()
ThisNetGrowlNotify.AsyncOpenUse = 1
ThisNetGrowlNotify.AsyncOpenTimeOut = 1000 ! 10 Seconds
ThisNetGrowlNotify.InActiveTimeout = 2000 ! 20 Seconds
ThisNetGrowlNotify.Open('127.0.0.1', 23053)
You will note that here we are sending the notifications to 127.0.0.1 on the local machine, but YES, you can actually send Growl notifications to OTHER machines on the network. For example, if one of the workstations suffers a database failure, you can send a Growl notification to the sysadmin on the server PC etc. Even simple 'chat' applications are possible without having to fuss over designing an interface.
The other beauty is that each workstation or operator can customise the way they see the Growl notifications. Some may want a simple 'bubble' popup. Others may want an iPhone style box, some may like the traditional OS X style. There are tons of styles in the public domain, and you can make your own as well.
http://www.growlforwindows.com/gfw/displays.aspxCheck the sample app here for more details. Feel free to lift the code and incorporate into your own apps as we do.
Cheers,
Devan
[attachment deleted by admin]