doc.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. Package uiserver creates a server to share an object (readonly) with clients.
  3. Background
  4. We want to deal with a user interface that is output-only: we only care about
  5. providing a representation of the internal state to users, not getting their
  6. input (that is, we'll do that part as a separate component).
  7. We also want the UI to be completely detached from the core, ie running as a
  8. separate process: to do so, bind a socket and exchange informations over it.
  9. This is especially reasonable when dealing with "embedded" boards where the
  10. outputs might be LED or OLED displays and the inputs might be pushbuttons so
  11. privilege separation is especially needed, but can prove useful in any other
  12. context.
  13. It must be easy to write a UI with a different programming language: to do
  14. so, gob is excluded, JSON is preferred.
  15. We assume that the "state" is pretty small, so caring about diffs will only
  16. be a waste of time.
  17. Protocol
  18. Bind a socket. Every UI is a client, which connects to our socket.
  19. Upon connection, send some "hello" just to check versions etcetera. Then
  20. send a serialization of the complete state. Upon change, just send it all
  21. again.
  22. Conversely, the client will read the socket and set the UI according to the
  23. state that has just been read.
  24. Usage
  25. The uiserver package implements a generic server specifically designed to
  26. send updates upon connection and whenever asked to (with NetUI.Update())
  27. */
  28. package uiserver