This is the sample source code to interface with my android application L2Bot Controller.
It simply takes basic text as an input and returns a string to the sender. This is written in java but can be ported to many languages easily to allow implementation in many platforms.
If you would like to download the file you can do so as well. http://mrrsm.com/downloads/TestConnect.java
package com.mrrsm.networking;
public class TestConnect {
/**
* @param args
*/
public static void main(String[] args) {
Server server = new Server();
Client client = new Client();
client.connect();
server.connect();
System.out.println("Connected");
String indata;
String outdata;
while(true){
System.out.println("Waiting for input");
indata = client.recieve();
System.out.println("Recieved: " + indata);
outdata = "";
if(indata.matches("Up")){
outdata = "Going Forward";
}else if(indata.matches("Left")){
outdata = "Going Left";
}else if(indata.matches("Right")){
outdata = "Going Right";
}else if(indata.matches("Down")){
outdata = "Going Backward";
}else if(indata.matches("Exit")){
outdata = "Exit";
}else
outdata = "Stop";
server.send(outdata);
if(indata.matches("Exit")){
break;
}
//System.out.println("Sent: " + outdata);
}
client.close();
server.close();
}
}
Robot Controller Server