Similar to TeamViewer, Vysor and AirDroid, I guess then. From a PC, it is easier since you can use ADB.
From Android to Android it is much more complicated....
Basically,
1) you need to find a way to communicate between the devices (which you seem to have already sorted out). You could use also Bluetooth, WifiDirect, WifiHotSpot.
2) Using the communication protocol you've set up, you can transfer screenshots from the rooted device to the controlling device and display them. Alternatively, you can send a video which creates a much smoother experience.
3) Then you need to trap touch actions, X and Y coordinates on the controlling device taking place on the displayed images and send them to the rooted device.
4) When the rooted device receives the X and Y (and action type such as a tap, long-click, slide, zoom-pinch), it needs to perform said actions. For this you need Accessibility Services.
5) and so forth...
I am working on a similar project, partly commercial for a client and for my own purposes.
I have implemented what mentioned above and it is working fine. However, I still need to glue them together, optimize code, do lots of testing and decide for alternative strategies if necessary.
If you are interested, you can contact me in PM to discuss this further.