I am trying to manage a program over a network using TCP and simple text commands (I will probably end up switching to binary data).
However, I wonder if there is a way to encode the data that the program sends and send it over the network, and then decode and transmit it to the recipient program? My current code is below, but I'm trying to find a better way than implementing it for the EVERY interface in ASCOM . Obviously, I will also have to write server-side code to complete the requested action. (FYI, this is one of the smaller ones.)
I believe that it uses COM in the message. Therefore, if COM data comes from outside (calling methods, setting properties, etc.), there should be no way to capture this data, transfer it over the network, and then transfer it to the recipient on another computer?
class SwitchConverter : ASCOM.Interface.ISwitch { private Client client = new Client(); private string query(string query){ return client.query(query); } private void send(string command) { client.send(command); } public bool Connected { get { return bool.Parse(query("SWITCHGETCONN")); } set { send("SWITCHSETCONN:" + value); } } public string Description { get { return query("SWITCHGETDESC"); } } public string DriverInfo { get { return query("SWITCHGETDRVI"); } } public string DriverVersion { get { return query("SWITCHGETDRVV"); } } public bool GetSwitch(short ID) { return bool.Parse(query("SWITCHGETSTAT:" + ID)); } public string GetSwitchName(short ID) { return query("SWITCHGETNAME:" + ID); } public short InterfaceVersion { get { return short.Parse(query("SWITCHGETINTV")); } } public short MaxSwitch { get { return short.Parse(query("SWITCHGETMAXS")); } } public string Name { get { return query("SWITCHGETNAME"); } } public void SetSwitch(short ID, bool State) { send("SWITCHSETSTAT:" + ID + "-" + State); } public void SetSwitchName(short ID, string Name) { send("SWITCHSETNAME:" + ID + "-" + Name); } public void SetupDialog() { throw new NotImplementedException(); } }
By the way, send and query are in another class that performs all communications. Very simple. You can find more information about ASCOM interfaces on the Ascom-Standards website: http://ascom-standards.org/
PS Regarding .NET Remoting?
source share