Programming NetMorphJapaneseVersion Programming NetMorphSince NetMorph 0.2 has eToy support, usually you do not have to write any Smalltalk programs. This page is for developers. First ExampleNetMorph 0.2 has well-defined API to control morphs remotely. Here is a sample. Suppose other image's ip and port is #('192.168.1.2' 37459).
After the trip, if you inspect the returned morph and send #path message, you can see the itinerary of the morph. CallbackYou can also subclass morph to do some special behaviors when it migrates.
Remote PerformIn NetMorph, any morph have its identifier. And if you know the identifier of a morph, you can invoke a method of the morph remotelly.
Morph ProxyIt is awkward to hold the identifier before the migration of morph.So there is a convenient method to return a proxy of morph.
The proxy return values and arguments are limited. You can not pass Blocks, thisContext, etc. But when the morph returns another morph, the client can automatically get the proxy of the returned morph. For example,
will return the proxy of the remote World. Overriding Morph>>stepIf you override Morph>>step, you can add an autonomous behavior to morph. So, you can write a network agent very easily.For example, if you would like to write a random wanderer in the net. The #step would be:
In the #step, these methods are useful.
Using MarkerMorphMarkerMorph is a visual remote pointer to a morph. By using it, you can control the morph remotely. This is usable to add a central control behavior to some autonomous mourphs.MarkerMorph is a normal morph, so it is possible to override #step. For example, if you would like to call back the remote morph periodically, you can override #step such as:
Morph>>leaveMarkerMorph returns a new MarkerMorph of the morph. (See the first example code). [:masashi | ^umezawa] |