C Bcode Cb Model

Back to the main documentation page

When designing and building the main Community Bar application, I was interested primarily in such questions as “Who owns this client?”, “Which places do they belong to?” and “Which items are in that place?” Rather than try to deal with these questions at the individual key/value pair level, and try to remember dependencies between them every time, I created the data model library. The data model library encapsulates all of the data dependencies between places, people and items in a Dynamic Linked Library (DLL).

Because a particular CB client uses the data model library, it manages data from the perspective of the client owner. The data model library acts as a controller, in the dMVC sense, by doing such things as subscribing and unsubscribing the owner to places and creating and deleting places and items (in response to user commands). It acts as a dMVC view by watching the list of the owner’s subscribed places for new items. When the client owner creates a new media item, the data model library manages the interactions with the server model. The library creates a new branch for the media item in the server keys and enters generic information about the Media Item – type, owner and place (see Figure 4.2) – in that branch. The Media Item internals manage all other information in the item sub-branch (e.g. the picture data for Presence items and the chat messages for the Chat item).

The data model library handles client interactions with the server data model. In its roles as a dMVC view and controller it sends commands to the server data model and receives notifications from the server about changes to the data model. The commands originate from the user who also has to be informed of data model changes. The CB client uses the user interface library, described next, to gather user commands and show an up to date view of the data model.

The data model library uses events to inform the main client application of relevant changes to the server data model, and the client then updates the user interface. The exception to this process is the internals of the media items. As should be clear by now, media items are separate from the rest of the client and, apart from creation and deletion, the only interaction the client has with them is to ask for views to place in the user interface reserved spaces.

Back to the main documentation page