Network game communication algorithms... small question
Just a (hopefully) quick question about getting input from the client side for passing information to a server. At the moment it is set up to take and send the input from the client once the return key is pressed, and send the whole line (with the system.in part). But obviously for a game to be played I am needing the client to send every individual key press from the client. I could try and use the read() method for the bufferedreader, but this returns an int, and I require a string so it can be checked in the server (as I am also going to have a server side representation of the game, as the project is to be investigating lag effects and different solutions to get around online game lag). Or could I use the read() method and use the returned int to find out from that key what was pressed and then change it to the key pressed from the int value returned, or is there a quicker way that doing this check?
I think there was a method that takes a character array as a parameter and I could somehow set the size to be only 1, so it would send every individual key pressed by the client, then allowing me to send this and display it at the server side? Or am I off on the wrong foot entirely...
This is the basic code of getting the actual input and then calling the methods which actually sort out writing to the streams elsewhere in the program:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
...
s = br.readLine();
if (s.length() > 0)
cc.sendMessage(s + "\n");
Thanks for any help given,
Cheers

