hello.
I am making a JOGL networked aplication, and here is what I am trying to do:
I have a few JSliders, that controls the atributes of a JOGL 3D object( a cube). So, if the user changes the position of the JSlider, it must send this information to all the other users, and then get the atributes changed.
here is what I done, but it isn]t working:
on the contructor:
try {
socket = new DatagramSocket(5000);
}
catch(SocketException socketException) {
socketException.printStackTrace();
}
on the state changed metod of the SliderHandler class (couse I olnly have to send informations when someone chage the atributes value)
try{
byte sendData[] = pacoteString.getBytes();
sendPacket = new DatagramPacket(sendData, sendData.length, InetAddress.getLocalHost(),5000);
socket.send(sendPacket);
byte reciveData[] = new byte[100];
receivePacket =new DatagramPacket( reciveData, reciveData.length);
socket.receive(receivePacket);
pacoteString = new String(receivePacket.getData(), 0, receivePacket.getLength());
token = new StringTokenizer(pacoteString);
flag = Integer.parseInt(token.nextToken());
valor = Float.parseFloat(token.nextToken());
System.out.println(valor);
if(flag == ROTACAO_X_CUBO)
renderer.setrotacaoCuboX(valor);
else if (flag == ROTACAO_Y_CUBO)
renderer.setrotacaoCuboY(valor);
else if (flag == ROTACAO_Z_CUBO)
renderer.setrotacaoCuboZ(valor);
else if (flag == TAMANHO_X_CUBO)
renderer.settamanhoCuboX(valor);
else if (flag == TAMANHO_Y_CUBO)
renderer.settamanhoCuboY(valor);
else if (flag == TAMANHO_Z_CUBO)
renderer.settamanhoCuboZ(valor);
else if (flag == POSICAO_X_CUBO)
renderer.setposicaoCuboX(valor);
else if (flag == POSICAO_Y_CUBO)
renderer.setposicaoCuboY(valor);
else if (flag == POSICAO_Z_CUBO)
renderer.setposicaoCuboZ(valor);
else if (flag == COR_VERMELHO_CUBO)
renderer.setcorCuboVermelho(valor);
else if (flag == COR_VERDE_CUBO)
renderer.setcorCuboVerde(valor);
else if (flag == COR_AZUL_CUBO)
renderer.setcorCuboAzul(valor);
}
catch (IOException ioException){
ioException.printStackTrace();
}
}
Should I made a diferent code for the client and the server? Couse the way it is now, it’s all the same.
What is happning is that it’s only sending the packet to itself, like there isn’t any other user runing the program.
I don’t have much experience, so any help would be very apreciated.
thx,
uderman