luvcraft/portal-server.lisp
Screen name -> function of a ready mirror which places it.
A listening Unix socket and the walls children may ask for.
session's portal server, started on first request.
environment with the variables that make a luvcraft started under it a
child of session appearing on screen.
When a child asks for screen, call placer with its ready mirror. placer
returns the portal it opened, or NIL to decline.
Negotiate with one connected child and put it where it asked to be.
The child end: luvcraft_PARENT_SOCKET in the environment.
Connect to the parent game at path and be a mirror child on screen.
The interactive block world built on luv.
A listening Unix socket and the walls children may ask for.
(session)Logical disjunction of tests and raw truth values.
(session)(session portal)(session screen environment)ENVIRONMENT with the variables that make a luvcraft started under it a child of SESSION appearing on SCREEN.
(session screen placer)When a child asks for SCREEN, call PLACER with its ready mirror. PLACER returns the portal it opened, or NIL to decline.
(session screen)Logical negation of one test or raw truth value.
(server client)A child luvcraft rendering into a ring of IOSurfaces this process owns. WIDTH and HEIGHT are the surfaces', in pixels.
(mirror &key (width 640) (height 400) (slots 3))Take MIRROR from a fresh child's hello to a ready ring: hear the hello, name a WIDTH x HEIGHT window (points), hear the pixel extent, make SLOTS surfaces that size, hand their IDs over, and hear ready. Returns MIRROR.
Logical conjunction of tests and raw truth values.
(mirror)(session portal)(&key (path (luvcraft-parent-socket-path))
(screen (or (uiop:getenv "LUVCRAFT_PARENT_SCREEN") "-")))(&key (input *standard-input*)
(output *standard-output*)
(screen "-")
(provider (make-instance 'luv:metal-gpu-provider)))Be the child: greet the parent on OUTPUT naming SCREEN, open a hidden game of the size the parent answers with on INPUT, tell it the frame's pixel extent, and from then on render into whatever surfaces INPUT names.
The portal server: a Unix socket where child luvcrafts come knocking.
A playing game listens on a socket and tells every shell it opens on a terminal wall where that socket is (
luvcraft_PARENT_SOCKET) and which wall the shell is on (luvcraft_PARENT_SCREEN). Any luvcraft started in such a shell notices the variables, connects instead of opening a window, says hello naming its wall, and the game here answers with a ring of surfaces and puts the child's picture on that very wall. Since the child is a whole game with walls of its own, it serves a socket too, and the shells on its walls can start grandchildren.