   Java sockets and my game
  hey everybody. im building my first 2d network game.im already facing a problem..public void run(){// We are now dealing here// with reading from socket and writing there// we understand protocol etc..while(running){try{String m = player.read();if(Gameprotocol.isPacket(m, Gameprotocol.CHAT_MESSAGE)){String mess = Gameprotocol.getAfterPeriod(m);window.logMessage(mess);} else if(Gameprotocol.isPacket(m, Gameprotocol.MOVE_ME)){window.logMessage("YO we can move");String mess = Gameprotocol.getAfterPeriod(m);String args[] = Gameprotocol.splitArguments(mess, 3);if(args.length == 3){int x = Integer.parseInt(args[1]);int y = Integer.parseInt(args[2]);player.moveTo(x, y); window.getFieldObj().drawPlayer(player);window.logMessage("YEP");}}Thread.sleep(1);} catch(InterruptedException e){}}}the problem is that my player moves, but sometimes he get's a little lag spike or something.. you know? like stops for millisecond, if i remove the thread.sleep(1), it seems to work okay.. is this plausible?my idea is that if my character wants to move, i send the 'can i walk' packet to the server and server replies and then my character moves/or not..all i have is chat message system&moving.. should i be worried that my game will be slow or something? i have to add many oter things yet..q2) i have yet to solve the cheating problem, what i thought is that when client connects to server, server assigns him an id and 24bit hash,id and hash will be combined into one string, like 6bit stringso there's like (26 + 10)^6 = 2 176 782 336 IDs.. doesnt seem so secure..i dont want to make too big control codes too.. because packet sending will take a little more then or so.. + in order to make packets more harder to read and modify by some WPE editors, i should encrypt before sending and decrypt on recieving.is there any other way to go around this? more logical one or better :)?or ehm what about this: on server side i map ID and IP address.. so when somebody sends me packet, where is 3bit ID, i can check if those are equal..this sounds like i can fake that too although[Edited by - Chr1sen on June 10, 2010 4:56:45 AM]