Recent Changes for "Example 4: Remote control of GUESS." - Graph Exploration System (GUESS)http://guess.wikispot.org/Example_4:_Remote_control_of_GUESS.Recent Changes of the page "Example 4: Remote control of GUESS." on Graph Exploration System (GUESS).en-us Example 4: Remote control of GUESS.http://guess.wikispot.org/Example_4:_Remote_control_of_GUESS.2007-08-11 00:38:26EytanAdar <div id="content" class="wikipage content"> Differences for Example 4: Remote control of GUESS.<p><strong></strong></p><table> <tr> <td> <span> Deletions are marked with - . </span> </td> <td> <span> Additions are marked with +. </span> </td> </tr> <tr> <td> Line 1: </td> <td> Line 1: </td> </tr> <tr> <td> </td> <td> <span>+ = Example 4: Remote control of GUESS =<br> + <br> + When loaded the following toolbar will allow you to telnet, or open a socket to, the machine running GUESS. Every command typed in the remote end will be executed in the GUESS client. The script is available as dockexample4, but is included below (to execute load the script and then type guessnetwork()):<br> + <br> + {{{<br> + import java<br> + import javax.swing<br> + import com<br> + <br> + # this is our toolbar<br> + class dockexample4(com.hp.hpl.guess.ui.DockableAdapter):<br> + <br> + myLabel = javax.swing.JLabel("Waiting for connection")<br> + <br> + def __init__(self):<br> + # add our toolbar<br> + self.add(self.myLabel)<br> + ui.dock(self)<br> + <br> + def getTitle(self):<br> + return("dockexample4")<br> + <br> + def update(self,val):<br> + # eval or execute the command as appropriate<br> + self.myLabel.setText(val);<br> + try:<br> + eval(val)<br> + except (SyntaxError,ValueError,NameError):<br> + try:<br> + exec(val)<br> + except (SyntaxError,ValueError,NameError):<br> + self.myLabel.setText("command error "+val)<br> + v.repaint()<br> + <br> + # extend the java thread object<br> + class guessnetwork(java.lang.Thread):<br> + <br> + # keep a reference to our toolbar<br> + screeninterface = None;<br> + <br> + def __init__(self):<br> + self.screeninterface = dockexample4()<br> + # start the thread<br> + self.start()<br> + <br> + def run(self):<br> + mySocket = java.net.ServerSocket(2222) # run on port 2222<br> + clientSocket = mySocket.accept() # accept a connection<br> + inst = java.io.BufferedReader(java.io.InputStreamReader(clientSocket.inputStream))<br> + val = inst.readLine() # read the line, and execute:<br> + while (val != None):<br> + self.screeninterface.update(val)<br> + val = inst.readLine()<br> + }}}</span> </td> </tr> </table> </div>