/// <summary> /// Called by Rhino when the user wants to run the command. /// </summary> protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var server_host_name = RockfishClientPlugIn.ServerHostName(); for (var i = 0; i < 3; i++) { var gs = new GetString(); gs.SetCommandPrompt("Server host name or IP address"); gs.SetDefaultString(server_host_name); gs.Get(); if (gs.CommandResult() != Result.Success) { return(gs.CommandResult()); } var name = gs.StringResult().Trim(); if (string.IsNullOrEmpty(name)) { RhinoApp.WriteLine("Server host name or IP address cannot be empty."); continue; } var host_name = RockfishClientPlugIn.LookupHostName(name); if (string.IsNullOrEmpty(host_name)) { RhinoApp.WriteLine("Unable to resolve host name \"{0}\".", host_name); continue; } var found = false; try { using (var channel = new RockfishClientChannel()) { channel.Create(); var echo = channel.Echo("Echo"); found = !string.IsNullOrEmpty(echo); } } catch { // ignored } if (!found) { RhinoApp.WriteLine("Unable to connect to server \"{0}\".", host_name); continue; } RockfishClientPlugIn.ThePlugIn.SetServerHostName(host_name); break; } return(Result.Success); }
/// <summary> /// Called by Rhino when the user wants to run the command. /// </summary> protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var rc = RockfishClientPlugIn.VerifyServerHostName(); if (rc != Result.Success) { return(rc); } var message = "Hello Rhino!"; rc = RhinoGet.GetString("String to echo", false, ref message); if (rc != Result.Success) { return(rc); } try { RockfishClientPlugIn.ServerHostName(); using (var channel = new RockfishClientChannel()) { channel.Create(); message = channel.Echo(message); } } catch (Exception ex) { RhinoApp.WriteLine(ex.Message); return(Result.Failure); } RhinoApp.WriteLine(message); return(Result.Success); }