How to build relay server?

I try to set up the relay server that control the flight info…
there are one or more gcs and each gcs controls cluster flight…
I wonder how to detect the connected gcs from each drone and inversely…
There is the sysid parameter in the mission planner. but i can’t have confidence…
Does it need to add another parameter for check connection?
Is there a sample source like that??