Просмотр исходного кода

start_app() no longer kills prior app; added tell_server()

Dave Schuyler 23 лет назад
Родитель
Сommit
9ea3af0608
2 измененных файлов с 23 добавлено и 5 удалено
  1. 9 3
      direct/src/directd/directd.cxx
  2. 14 2
      direct/src/directd/directd.h

+ 9 - 3
direct/src/directd/directd.cxx

@@ -146,11 +146,18 @@ DirectD::~DirectD() {
 }
 }
 
 
 int 
 int 
-DirectD::client_ready(const string& client_host, int port,
+DirectD::client_ready(const string& server_host, int port,
     const string& cmd) {
     const string& cmd) {
   stringstream ss;
   stringstream ss;
   ss<<"!"<<cmd;
   ss<<"!"<<cmd;
-  send_one_message(client_host, port, ss.str());
+  send_one_message(server_host, port, ss.str());
+  return 0;
+}
+
+int 
+DirectD::tell_server(const string& server_host, int port,
+    const string& cmd) {
+  send_one_message(server_host, port, cmd);
   return 0;
   return 0;
 }
 }
 
 
@@ -204,7 +211,6 @@ DirectD::server_ready(const string& client_host, int port) {
 void
 void
 DirectD::start_app(const string& cmd) {
 DirectD::start_app(const string& cmd) {
   nout<<"start_app(cmd="<<cmd<<")"<<endl;
   nout<<"start_app(cmd="<<cmd<<")"<<endl;
-  kill_app();
   _app_pid=StartApp(cmd);
   _app_pid=StartApp(cmd);
   nout<<"    _app_pid="<<_app_pid<<endl;
   nout<<"    _app_pid="<<_app_pid<<endl;
 }
 }

+ 14 - 2
direct/src/directd/directd.h

@@ -45,7 +45,7 @@ typedef int intptr_t;
 //              There are two API groups in this class, they are:
 //              There are two API groups in this class, they are:
 //              
 //              
 //                listen_to()
 //                listen_to()
-//                client_ready()
+//                client_ready() or tell_server()
 //                wait_for_servers()
 //                wait_for_servers()
 //                server_ready()
 //                server_ready()
 //              
 //              
@@ -82,7 +82,19 @@ PUBLISHED:
   //              A new connection will be created and closed.  If you
   //              A new connection will be created and closed.  If you
   //              want to send more than one command, you should use
   //              want to send more than one command, you should use
   //              connect_to(), send_command(), and disconnect_from().
   //              connect_to(), send_command(), and disconnect_from().
-  int client_ready(const string& client_host, int port, const string& cmd);
+  int client_ready(const string& server_host, int port, const string& cmd);
+
+  // Description: Tell the server to do the command cmd.
+  //              cmd is one of the following:
+  //                "k"    Kill the most recent application started with
+  //                       client_ready() or "!".
+  //                "q"    Tell the server to quit.
+  //                "!cmd" Exectue the cmd on the server (this is a dos shell
+  //                       command; if you want a bash command, include bash
+  //                       in the command e.g. "!bash pwd").  When you call
+  //                       client_ready(), it prefixes "!" for you.
+  //              A new connection will be created and closed.
+  int tell_server(const string& server_host, int port, const string& cmd);
 
 
   // Description: Call this function from the client after
   // Description: Call this function from the client after
   //              calling <count> client_ready() calls.
   //              calling <count> client_ready() calls.