major refactor

every instance of lan-mouse can now simultaneously send and receive
events
This commit is contained in:
Ferdinand Schober
2023-01-30 19:15:58 +01:00
parent 5c60e2eb58
commit 5222f54eee
15 changed files with 923 additions and 528 deletions

30
DOC.md
View File

@@ -51,3 +51,33 @@ sequenceDiagram
Bob-->>-Alice: Ack (Keyboard Layout)
```
## Problems
The general Idea is to have a bidirectional connection by default, meaning
any connected device can not only receive events but also send events back.
This way when connecting e.g. a PC to a Laptop, either device can be used
to control the other.
It needs to be ensured, that whenever a device is controlled the controlled
device does not transmit the events back to the original sender.
Otherwise events are multiplied and either one of the instances crashes.
To keep the implementation of input backends simple this needs to be handled
on the server level.
## Device State - Active and Inactive
To solve this problem, each device can be in exactly two states:
Events can only be sent to active clients.
Events can only be received from inactive clients.
Active denotes that a particular device is controlled by the local pc.
Any event received from an active device is ignored unless it is a state change request.
In this case the device is marked as inactive and no further events are sent to the device.
The received events are then processed until a further state change to active
is requested (when the corresponding layer surface is entered).
**In short:** The invariance "each client either sends or receives events" must
always be true.