Note to self: Distributed Objects

A blast from the past: This is a three-year old article draft. It's a joy for me to see that marvellous Smalltalk syntax again. :-)

To remind myself how to use Apple's/GNUstep's distributed objects: The GNUstep manual sums it up quite nicely. Here's the code the Pracmatic Smalltalk way:

To provide a service...

| connection |
connection := NSConnection defaultConnection.
connection setRootObject: rootObj.
(connection registerName: 'a service name') ifFalse: [ "handle error" ].
"if not an application:"
NSRunLoop currentRunLoop run.

To use a service...

| proxy |
proxy := NSConnection
  rootProxyForConnectionWithRegisteredName: 'a service name'
                                      host: hostName
                           usingNameServer: NSSocketPortNameServer sharedInstance.