so ive been learning to write a server and here is what i have so far.as you can see im up to player updating. But I dont get where to begin. it says the client begins by reading 1 bit so do I write to the client right after the login? also any tips or anything about what I wrote let me know. thanks.Code:public static void main(String[] args) throws IOException {
//begin login
try {
final ServerSocket serverSocket = new ServerSocket(43594);
final Socket clientConnection = serverSocket.accept();
DataInputStream in = new DataInputStream(clientConnection.getInputStream());
DataOutputStream out = new DataOutputStream(clientConnection.getOutputStream());
System.out.println("Connect status: " + in.readUnsignedByte());
System.out.println("Specific user id: " + in.readUnsignedByte());
out.writeLong(0); //ignored 8-bytes
out.writeByte(0); //response code: 0
Random rand = new Random();
out.writeLong(rand.nextLong()); //randomly generated server session key
System.out.println("Login code: " + in.readByte());
System.out.println("Size of packet: " + in.readByte());
System.out.println("Magic number: " + in.readUnsignedByte());
System.out.println("Protocol revision: " + in.readShort());
System.out.println("Client version(0=low, 1=high): " + in.readByte());
System.out.println("CRC value 1: " + in.readInt());
System.out.println("CRC value 2: " + in.readInt());
System.out.println("CRC value 3: " + in.readInt());
System.out.println("CRC value 4: " + in.readInt());
System.out.println("CRC value 5: " + in.readInt());
System.out.println("CRC value 6: " + in.readInt());
System.out.println("CRC value 7: " + in.readInt());
System.out.println("CRC value 8: " + in.readInt());
System.out.println("CRC value 9: " + in.readInt());
System.out.println("Remaining size: " + in.readByte());
System.out.println("RSA opcode: " + in.readByte());
System.out.println("Client session key: " + in.readLong());
System.out.println("Server session key: " + in.readLong());
System.out.println("User ID: " + in.readInt());
out.writeByte(2);
out.writeByte(0); //player status 0=player, 1=mod, 2=admin
out.writeByte(1); //info on mouse movements,etc.
//end login
//begin player movement updates
//temporary
clientConnection.close();
serverSocket.close();
} catch (IOException x) {
System.out.println(x);
} finally {
}
}
