Gerry's suggestion is excellent - there is no point in reinventing the wheel, particularly for a complex (and error prone) task like this.
Another option is Chrome Remote Desktop - Chrome Web Store
Quote:Access other computers or allow another user to access your computer securely over the Internet.
Chrome Remote Desktop allows users to remotely access another computer through Chrome browser or a Chromebook. Computers can be made available on an short-term basis for scenarios such as ad hoc remote support, or on a more long-term basis for remote access to your applications and files. All connections are fully secured.
Chrome Remote Desktop is fully cross-platform. Provide remote assistance to Windows, Mac and Linux users, or access your Windows (Windows 7 and above) and Mac (OS X Yosemite 10.10 and above) desktops at any time, all from the Chrome browser on virtually any device, including Chromebooks.