Montag, 11. August 2008

The simple example: 2D Tweak embedded app in a 3D Croquet window


I am investigating how to integrate a Tweak app with Croquet. Read on for a little intro. Get it:
The code of the simple example and the Tweak-in-Croquet TEmbeddableApp implementation.

There's currently certainly the 2D-overlay menu of for example the KAT Demo which is implemented in Tweak. But besides that what really matters to me is to have 3D windows with Tweak apps inside. Example (do you find the bug?):
The bug is the missing synchronization. You see that each Croqueteer is seeing the app in the 3D-space. They don't see the same state in the apps. The apps work in that the events are distributed, but the problem is that the lower Croqueteer joined late. The app had already received events and advanced its state when the lower Croqueteer joined. But his app displayed 0 on the counter when for the upper Croqueteer it was showing 5.

Why is that? Actually the architecture of TEmbeddedApp is creating an app locally, next to each replica of the island (don't know the terms? Look at the Croquet Architecture Introduction). There's a mechanism in CroquetHarness, #updateEmbeddedAppsIn:, which handles the creation of the local copies for the embedded apps.
Embedded apps are of course not in the island - so during sync they aren't snapshotted and copied over to the joining node. They need to care for this synchronization themselves. That's what the appData in the TEmbeddedApp object is good for. Every app instance needs to update its replica's appData-copy. No joke (and no network traffic for this)! That's the current architecture for embedded apps. SyncSend is the keyword, with it you are accessing island-data directly.
So if you want to build an embedded app - or integrate an existing Tweak app, then you have to provide means to load existing state from the appData and of course you have to store each change to the app's state in the appData object. See CSimpleEmbedTweakPlayer's state-mgmt category in the provided code.

That's also how the morphic app KTextApp/KMediaText is working:
Thanks to hrs and jcg for this example, and thanks to Andreas Raab for the embedded Morphic World - both served as excellent examples.

I am currently investigating a framework for the creation of embedded apps. The state-saving should be supported by a framework and the default widgets should provide adapters for this kind of state-persistence. I hoped I can sooner provide a demo for that, but I dragged on so I created this simple demo for the meantime.

I hope that this draws some comments! :- )

3 Kommentare:

Georg hat gesagt…

Answer to Feedback from Kiran: To run the simple demo there is a class method on the TSimpleEmbedTweakApp.
Use the KAT Demo, say Explore Harness in the Admin Menu and do

TSimpleEmbedTweakApp createInHarness: self

in the lower part of the a KStandardHarness Window.

Cheers!
Georg

Georg hat gesagt…

The code of Croquet-Embed-Tweak-GK.10.mcz is released with Copyright under the Croquet License as used for the Croquet SDK on http://www.opencroquet.org.

Rashid Mallah hat gesagt…

if you want Best iPhone Tweaked Apps then Must try it.. tweaked apps