February 2013 | Download Project (zip)
As a core module on second year, I have to do Networking. I know a lot of people find it hard/boring but I didn’t mind it. This is my first project I have done in Java apart from small little things to learn the language. I think the tougher side behind it was thinking about how to design the program and make sure data was synchronized correctly. I had to use a tutors jar file and interface with it but I was only in charge of the networking side.
Overall, I got the majority of the ICA done which included the following:
- TCP & UDP Connectivity
- Clients can see others move/turn
- Handling of multiple users by threading
- Implemented basic Rock, Paper, Scissors
- Client stats on server (If server restarts it will all be gone though!)
- Due to above, clients will keep data when joining with same Username
- Client states, can’t interrupt someone playing
I’ll admit there are bugs, such as someone joining with the same username and such. Although they probably wouldn’t be too hard to solve. For example, since I had to use a tutors API which had a few bugs its self, it was pretty tough figuring out if I was the problem or not. In some cases when the client joins, they would appear in the upper left rather than the position that comes through when they join via UDP. A work around would be to send it through TCP on join to make sure the information arrives with the client ID, however that was out of my control.
Another bug was that when using the same Username to rejoin and get your data back, it’s all well and good. However if another client joins, things go wrong. A way to fix this would be a server side check to see if that account was in use and then send a message back saying to choose a different name. However the client side which I didn’t control just joins and sends the message anyway.
Anyhow, it was fun to give networking a go and wouldn’t mind doing it again as long as I am in a little more control and understand what was needed.