Watch this short video introducing network protocols:
We're going to start on building a networked program tomorrow in class. To help get things started, please follow the directions below to create two new projects in Eclipse and import the necessary code.
Create a Java project (not a leJOS EV3 project!) called "Computer Client". Download and add the following classes to the project:
Create a leJOS EV3 project called "Robot Server". Download and add the following classes to the project:
You should resolve all package errors so that the programs compile and are ready to run. Note that the first project runs on your computer (it opens a window on your laptop) and the other is a standard program that runs on your robot. You can try the "Computer Client" program on your laptop before coming to class.
ComputerClient
class has a send(String)
method that will send a message to the server. Add this to your keyPressed()
method (for example, put send("Hi");
in there).RobotServer
class has a request(String)
method that receives what the client sends. You can examine the String and build a large if-then statement to take different actions. For example, if the input string was "go", you might start moving both of the motors...