[Nano-X] Fix various problems with multiple client/server Nano-X by ghaerr · Pull Request #2215 · ghaerr/elks (original) (raw)

Debug and fix nxtetris problem using GrGetNextTimeout described in #1810 (reply in thread).

Fixes server error when handling multiple clients.
Ignores ^C instead of exiting (use ESC to exit).

Sets default Nano-X build to client/server.

@tyama501, finding all the problems and getting this working proved to be far more complicated than I thought. Long story short, we can't directly send a timeout to the nano-X server because it is servicing multiple clients - thus when a timeout is required when getting an event, the server is put into a "polling" mode where it times out every 50msecs and then calls back to each client waiting for a timeout to measure whether the elapsed time has been long enough. There was also a major bug where the server would reply to the wrong client in certain cases.

So far, I've been able to get two clients or so working well with the server. Adding more in some cases causes some window remapping problems. So for now I'm staying with just getting one or two clients working well. Go ahead and experiment and see what other problems you might find. I see there are a couple ifdef CONFIG_PC98 in the srvmain.c code which will likely have to removed or changed, as soon as I get the UNIX sockets working on FAT, which is my next step.

After spending all day in this code, I'm seeing there's still a lot of cleanup to be done, but this should be a big step forward.

Here's a video of nxclock running with nxtetris, run using the following script:

nano-X & sleep 1; nxclock & exec nxtetris

nxtetris.mov