Bluish Coder

Programming Languages, Martials Arts and Computers. The Weblog of Chris Double.


Multiple Users in a Self World

One of the things I like about the Self programming language is it has lots of interesting old projects written in Self included in the source distribution. These include a Dylan interpreter, Cecil interpreter, web browser, and partial Java implementation amongst other things.

Once of the features Self has is the ability to allow remote users to connect to a Self instance running the Morphic user interface. This is usually done using X11's facility to share remote windows. But included in the Self source is a client written in Java and a server written in Self that allows remote users to connect using a Java Applet in a web browser.

The code for this has bitrot slightly but I've updated it just enough to work and demo. My fixes have been merged into the official Self repository on github.

Server side

With these changes and a build of Self you should start with a fresh image containing the Morphic code (UI2). From the self console run:

$ cd objects
$ ../Self 
"Self 1" 'applications/javaServer/loadJavaServer.self' _RunScript

This will load the server code. It's best to do this in a fresh instance as it modifies some UI objects that result in Self having to rebuild a number of dependencies for the objects in the system. This can make an existing system sluggish for a bit.

Once loaded, start the desktop:

"Self 2" desktop open

From a shell in the desktop, create a copy of the javaDaemon object using 'Get it' and put it somewhere:

javaDaemon copy

The outliner for this allows changing the port slot if needed, which defaults to 1420. Middle click on the outliner's title and choose 'Show Morph'. This creates a default tan square that can be placed anywhere. The world that this morph lives in is the world that remote users will connect to.

From the outliner run the start method. There will be a prompt warning you that this is a security issue as you're allowing remote access to your machine. Answering Yes will run the server.

Client side

The client code is written in Java. The source is in objects/applications/javaClient. The shell script BuildJavaClient will build the Java code. The Test.html page in that directory should be served from a web server and accessed by a web browser. Note that due to Java security settings this must be served from an actual web server. I used a local thttpd instance. There may also need to be some changing of Java Applet settings in the Java control panel to allow the applet to make socket connections.

Once 'Test.html' is loaded you can enter a username, keep the password empty, and connect. You should now see the Self desktop.


Unfortunately when the client connects sometimes the Self desktop stops and it won't respond. To restart it enter in the Self console:

desktop go

When this is done you'll see the remote users 'hand' (Self term for mouse pointer) in the Self desktop as an arrow with their name. A border will be in the world with the color of the user showing the extent of the desktop that the user can see in their remote session.

Dragging items around in both sessions is reflected in the world. Other users can connect too. The Java client uses 'Shift+Left Click' as the right mouse button and 'Control+Left Click' as the middle mouse button.


I did a short screencast of using the remote sharing to show how it works. If your browser supports HTML video it should show below.


I think a dedicated protocol like this is probably better than using remote X11. Self currently is quite tied to X but if it could be moved off it it would allow easier porting to Windows, Android and other non-X platforms. Perhaps using something like SDL2 to get cross platform and hardware acceleration.

More information about the protocol and implementation of the Java client is available in JavaClientServerOverview.txt

An interesting project would to be port the javaClient code to JavaScript using an HTML canvas or WebGL to display the remote work. The server could be updated to communicate via HTTP, WebSockets, or even WebRTC's peer to peer facilities.


This site is accessable over tor as hidden service 6vp5u25g4izec5c37wv52skvecikld6kysvsivnl6sdg6q7wy25lixad.onion, or Freenet using key: