10.07.2015 Views

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Note particularly the highlighted code at the end. We check the initializedOutsideinput parameter to see if the server has already done this task for us. The #defineST_DDA_API_NOTES can be found in the stDdaApiDefs.h header. We call alocal routine that simply calls NotesInitExtended(). The initializedInside outputparameter is always a copy of the initializedOutside flags plus whatever weinitialize ourselves (so that the server knows not to init Notes again). We keep acopy in a global variable so that we will remember to terminate Notes later.The correspondingly modified stDdaClTerminate routine code is shown inExample 5-3.Example 5-3 Modified stDdaClTerminate() code to Handle Notes API terminationvoid ST_DDA_APIstDdaClTerminate(){if (globalInitMask & ST_DDA_API_NOTES)TermNotes(RecorderInst);globalInitMask &= ~(ST_DDA_API_NOTES);} // end stDdaClTerminateThe local TermNotes() routine simply calls NotesTerm(), and does whateverother global cleanup our logger requires.Note that neither the Init nor the Term routines requires synchronization toprotect global variables (such as the globalInitMask variable in Example 5-2 onpage 137 and Example 5-3). These routines are guaranteed to be called on asingle thread, one at DLL load time, and one at server shutdown time. In fact, theentire Sametime chat logging SPI is documented as being single-threaded,which means that there is no need to write code defending against concurrentaccess to global state.If your logger does substantial work on server invocations, however, the fact thatthe calls are synchronous from the server to the logger DLL could cause theserver to slow unacceptably. The best way to work around this would be to haveyour callback routines simply take the given input parameters and copy them toan in-memory queue of some kind, and then return right away. You would thenhave one or more background threads that picked "messages" off the end of thequeue and processed them.Finally, to activate the created chat logging DLL, start and stop the Sametimeserver on which the DLL is installed. If the Sametime community contains morethan one Sametime server, start and stop all servers in the community.138 <strong>Lotus</strong> <strong>Instant</strong> <strong>Messaging</strong>/<strong>Web</strong> <strong>Conferencing</strong> (Sametime): Building Sametime-Enabled Applications

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!