• 11
• 9
• 10
• 9
• 10
• entries
208
383
• views
65737

# Yar!!!

98 views

I was just able to successfully control a JavaTactics that was running on my brother's computer in Oregon! I could chat, and move the camera around! XD

Although I do now have a question: If a small amount of information (a string such as "ae 0231") needs to be sent, is it degrading the time to send the information if I open and close the socket each time? I have a feeling that I should keep the socket open (especially for chat), but the way I have my code set up right now it only opens the port when I send out commands...

So I was thinking... should each JavaTactics instance have an array of connected computers? This way if a new computer connects to any of the ips it auto gets the other player's ip? This way I can keep sockets open too...

But either way, just *so* happy that it worked.

Sample communication:
~>java Requester 198.92.66.53 2004Connected to 198.92.66.53 in port 2004.server>Connection successfulclient>JTC: Get offline and call me.server>Completed JTC.client>SSO: ae 0231server>Completed SSO.client>byeClosed connection to 198.92.66.53 in port 2004.

JTC stands for JavaTacticsChat, and SSO stands for ServerSideOperation (such as moving an actor etc)

Congrats!

Quote:
 So I was thinking... should each JavaTactics instance have an array of connected computers? This way if a new computer connects to any of the ips it auto gets the other player's ip? This way I can keep sockets open too...

I personally don't know how you plan on implementing the final game, but assuming you will let several clients play at once, you would certainly want some sort of "lobby" system, so you can deal with player connections at the beginning, and only have to deal with player "drops" in game, and not new connections. And yes, you will want to keep an arraylist or something of the other IPs...you should know them anyway from when you recieve a request to open a socket.

Also, why would you want to close your socket. I have never worked with Java for networking, but if it is anything like C, then closing a socket closes the connection...and reestablishing a tcp connecting (maybe you are using udp?) for every single piece of data sent is...wayyyy overkill. Keep 'er open.

Or maybe I am misunderstanding you.

Nope, thats what I'm doing! I figured when I was writing it that since at max it would send information about every 10 seconds... then I remembered about chat... But I have no experience with network programming, so frankly I didn't know much of what I was doing.

But yeah, plan on keeping the sockets opened... just need to get to writing it... :D

On another note, I've only got a midterm paper to hand in, and one more midterm to take, then I can spend all the time I want on this (at least as long as my mind can handle...)