Need some advice/help on an assignment
Working on the last assignment in my Java programming class and I am having an issue. The project is a combination of an earlier project combined with networking.
Earlier we created a Tangram program where you can move pieces and form shapes with them and so on. Now we have to combine that project with networking and have two people move pieces. Here is the description page for the assignment: P6
The way I am handling the assignment is by sending MouseEvents to the other user when they move a piece. The other user will then receive this MouseEvent and pass it in the appropriate function that will update the corresponding piece on their program. I know that it works because just for testing purposes, I set up one side to only send events and the other to only receive. The problem I am having is trying to make them work back and forth, going both ways. Here is some code showing how one side receives and handles it:
The code above is the code that solely handles incoming input, and it works if I dedicate the other side to solely sending output. When I try to make the code equal on both sides, to make the server and client simultaneously send/receive output and input, it doesn't work. This makes me think I need some kind of thread that will work independently to send output while the above function will handle the inputs. Would this make any sense?
public void processConnection() throws IOException
event = (MouseEvent) input.readObject();
if (event.getID() == 501) // Mouse Pressed
if (event.getID() == 506) // Mouse dragged
if (event.getID() == 502) // Mouse Released
catch ( ClassNotFoundException classNotFoundException )
} while (ClientActive != false);
Re: Need some advice/help on an assignment
What exactly do you mean by "it doesn't work"?