
Include Files re IBM
====================

This example relies upon having a set of .hh files for the Workplace Shell. 
Unfortunately while IBM ships the interface definition files (.idl) with the
VisualAge C++ compiler, they are still working on adding a set of .hh files.

They do, however, provide a script named WPIDL2XH.CMD to generate the older
(non-DTS) .xh files.  Therefore I took that script and modified it to make
.hh files instead.  IBM reports that there are problems in their .hh emitter
that the SOM group in Austin and the VAC++ group in Toronto are working out
so it has sometimes been necessary to hand-edit the .hh files very slightly.

I am including my WPIDL2HH.CMD script so that the readers of this article
can generate their own includes until the next release of VAC++, due early
May.


File List
=========

makefile       Makefile Suitable for Use with VAC++ NMake
makefile.omk   Makefile Suitable for Use with OpusMAKE

chatroom.hh    SOM Declaration of the Chatroom Class
tchat.hh       SOM Declaration of the TChat Class

useful.hpp     Some Useful C++ Declarations
bkthread.hpp   Background Thread - Class Declaration
chatview.hpp   Open View of a TChat Object - Class Declaration

tchat.cpp      Implementation of TChat SOM Class
m_tchat.cpp    Implementation of TChat SOM Metaclass
chatview.cpp   Implementation of Open View of a TChat Object
bkthread.cpp   Implementation of the Background Thread
chatroom.cpp   Implementation of the Chatroom SOM Class

tchat.h        Defines for Resource IDs
tchat.rc       Resource Definitions for the Menu Items
tchat.ico      Primary Icon for Desktop TChat Object
tchat2.ico     Secondary Icon for Desktop TChat Object

TChat.dll      TChat Class Packaged as a SOM DLL
Chatroom.dll   Chatroom Class Packaged as a SOM DLL

try.cmd     
vacmake.ini    OpusMAKE Initialization File for Use with VAC++
wpidl2hh.cmd   Script to Generate .hh Files from .idl Files


Debugging Tips
==============

Throughout the source code we call somPrintf() which prints to the SOM trace
log, which is STDOUT by default.  In server classes like Chatroom, this
causes the output to scroll in its process window..  In Workplace Shell
classes such as TChat, it means you must redirect the output of WPS to a
file.  To do this, change the RUNWORKPLACE line in your CONFIG.SYS file from
"C:\OS2\PMSHELL.EXE" to "C:\OS2\CMD.EXE".  Now when you boot, you will be
left at a command prompt in a window on a blank PM screen.  In that window
you can delete or rename your DLLs since they are not locked by WPS.  To
start the desktop and capture the output of any somPrint() calls, enter the
command "PMSHELL >C:\WPS.LOG".  Now you can TYPE the output that WPS.LOG at
any time to see what your classes are doing.  You can also switch back to the
command window in which you invoked PMSHELL and type Control-C to shut down
just the desktop, not your system.  This is useful if your SOM WPS class did
something wrong and you need to forcibly stop it.

Setting Up the Sample Application
=================================

The DLLs tchat.dll and chatroom.dll must be placed into a directory in your
libpath in some manner.  Then run PREGIMPL.EXE to define the chatroom(s) you
wish to operate.  For each room, set the alias to the name of the room, the
Server program to 'somdsvr.exe', Multithreaded to 'No', Server class to
'Chatroom', leave the two fields about 'Object ref...' blank and set the
'Host name' to the name of the machine on which you want the chatroom to
reside.  Do this on all machines since clients use the repositories to locate
the servers and SOMDD.EXE use it to instantiate the server processes on
demand.  SOM server processes, once started, never go away automatically. You
must kill them manually by typing a Control-C in their window.

Start the necessary background SOM daemons on each machine by running
"WPDSINIT /s".  This starts the SOMDD.EXE daemon and it also starts a SOM
server thread within the Workplace Shell itself.  This server thread is
necessary for the remote Chatroom object to be able to issue method calls
back to the TChat objects on your desktop.  A pure client/server setup
doesn't need it but our chat setup is more of a peer/peer arrangement.  You
will see an entry in the implementation repository for the Workplace Shell as
well.

Run the TRY.CMD script to register the TChat class with the Workplace Shell
and create two example TChat objects.  Open one up and starting typing in the
lower pane and you will see the other one's icon change to indicate
attention.  Open it up and type back to yourself.

To shut down, delete the TChat objects and then shutdown the daemons by
running "WPDSINIT /k".  The wrong order can result ina process trap.


Tau Productions Inc.
Jeff Rush (jrush@onramp.net)
http://rampages.onramp.net/~jrush/somwork.htm

