I would like to use system.net.getHostName() to tell when a certain machine is running the view or not.
So far everywhere I tried to bind this in a script it runs through the gateway scope and returns the gateway hostname, where should this be placed to find the device hostname running the perspective view?
Calling scripts via Perspective all run on the gateway and hence are gateway scoped. If you need hostname from the client, you'll need to use the session.prop.host prop. There are some caveats using this though as it will likely return an ip rather than a hostname. There's an option in the gateway config to attempt to get this, but I forget where it is... I'll be back, as Terminator said (unless someone else jumps in first)
But be aware that it will show a NAT router address instead of an actual client if there is one in the path from client to gateway.