Skip to main content

Communicating between classes in Wonderland

1 reply [Last post]
Joined: 2009-11-24

Hi all!

I have two seperate modules (both derived from the Whiteboard module) which I need to communicate with each other. I have a bunch of seperate instances of one module sending SVG documents to a static vector in another module.

I essentially want all the whiteboards in the world to send their SVG data to a few 'display boards' when the user clicks a specially created 'save' button, and for the whiteboard to load all SVG documents in a static vector when they click a specially made 'Load' button on the 'display board'.

My problem is how to send this SVG document from one whiteboard instance to the static vector in the 'display board' module, from button click on the client to the server instance on the display board. How do I tell the server side component of a whiteboard instance to send the SVG document, and how would I add this SVG document to the display board class's static vector?

Thanks for your help, it is very much appreciated! Totally stuck right now!


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-07-13

Here is how I would approach the design. I imagine on the server side you have two modules, "whiteboard" and "displayboard". To start with, a little setup:

1. displayboard, in addition to handling the display board objects in world, also exposes an interface on the server that can be used to load and save SVG data. The implementation of the interface will be a singleton in the Darktar server, which you can build using a binding in the Darkstar data manager.

2. whiteboard will depend on displayboard, so it can import and use the interface defined above.

Once you have this setup, the control flow would be as follows:

1. user clicks "save" on the whiteboard.

2. the whiteboard cell on the client sends a message to the WhiteboardCellMO on the server.

3. when the WhiteboardCellMO gets the message, it captures its current whiteboard SVG content. You can do this by calling "getServerState()" on the WhiteboardCellMO. The resulting WhiteboardCellServerState contains the SVG content as a variable.

4. using the interface designed above, the WhiteboardCellMO will discover the display board singleton object. It can then call a method on this interface to "post" the SVG content.

5. when the data is posted to the display board singleton, the data now moves to the displayboard module. The display board module can, at this point, send a message to the client-side display boards with the updated data.

6. when the displayboard client receives the message, it can update the display with the new data.

This is not simple to implement, but we use similar designs in the shared application server, for example.