Wednesday, October 14, 2009

Section 5.3.  The Chat Model










5.3. The Chat Model


At this point, the Contacts view is empty because there is no underlying list of contacts to show. That is, Hyperbola does not have a model. A model that supports Hyperbola's chat domain will prove helpful as we work through building the application. You could go straight to a messaging library and start implementing the UI pieces on top of its model. But, there is a danger that the UI work will get bogged down in the details of sending bytes around. What we really need is a simple chat model that has all the right entities and is sufficient to drive the UI parts of Hyperbola. When it comes time to use a real chat library, there will be some rework needed, but hopefully not too much.


The Hyperbola chat model shown in Figure 5-8 is very basic. Sessions comprise the central object. They allow connecting to a messaging server and provide access to contacts, which are either groups or individuals. A Session has a reference to the root group for the logged-in user. Listeners can be attached to Sessions and receive notifications when the root ContactsGroup changes.



Figure 5-8. Classes in the prototype chat model

[View full size image]




You can code the model yourself, or to save time, you can copy the code for this chapter using the Samples Manager described in Section 3.6, "Sample Code." Here, you only want part of the sample code, so copy just the package called org.eclipsercp.hyperbola.model by selecting the package in the top part of the Compare editor and selecting Copy to Workspace from the context menu.












No comments:

Post a Comment