Computer Science Canada Live Chat |
Author: | S_Grimm [ Thu Oct 23, 2008 6:20 pm ] | ||||
Post subject: | Live Chat | ||||
Our programming class is divided into to class. the senior class(grade 12's) (4 people) and the junior class (grade 11's) (24 people). so the grade 12 class decided that we would like to be able to talk to each other without disturbing the teacher while he is teaching the grade 11 class. Hence the idea of a "Live Chat" was created. I have already O.K.ed this with the teacher, he say's it's a great idea... And i managed to get the basic program running. I can send and receive messages on two different computers on the network. unfortunately, I can only sen and receive in a specific order. ie. send, receive, send, receive or vise-versa.
That is the Server or Host computer.
that is the Client or remote computer. it works, but i want to be able to say open it up to 4 people AND allow multiple incoming messages in a row (ie receive, receive, send, receive) from any of the people connected. Any help/ advice would be appreciated. P.S. Please don't knock the idea. The class is a high school programming class, and we really don't like to shout halfway across the room, over the grade elevens and the teacher. and we don't really want to move across the class either. |
Author: | HellblazerX [ Thu Oct 23, 2008 7:27 pm ] |
Post subject: | Re: Live Chat |
You might want to look into Threads. Threads are like processes in Turing, but not done so poorly. Basically you'll want separate threads for your server and clients, that way they won't interfere with one another if one goes idle. I did do some networking in high school, but it's been a while, so I've pretty much forgotten it all. I'll dig around my harddrive and see if I can find the files for it. |
Author: | S_Grimm [ Thu Oct 23, 2008 7:37 pm ] | ||
Post subject: | RE:Live Chat | ||
thanks. ill look into it. edit: i was digging around in some stuff i had on my hard drive, and managed to find and modify this from javanotes5.0.2 edit 2: updated the code.
The Issue I have with this now is trying to run an ServerSocket on it to accept incoming connections. I also need to be able to use a PrintWriter in this, by in order to do it, i need to call ServerSocket and a Socket variable. When i try to put the code into the actionPerformed section, it refuses to reconize the Socket. any ideas. (ps. When (if) this gets running, feel free to use it, modify it, or download and delete it) |
Author: | S_Grimm [ Mon Oct 27, 2008 10:57 am ] |
Post subject: | Re: Live Chat |
Alright. I got the server to open up multiple ports and be able to recieve data. so far it is working... except for the fact i can only send or recive in that order. I couldn't find a tutorial on threads, before anyone asks. ill post the code. note: you need to manually punch in your ip address in the client program. shouldn't be hard to find where, i have a default ip address in there (192.168.0.100), just change it and make sure the port number (the number beside the ip address is 5050). if you are using 2 client computers change the port on the second one to 5051. please note that you need at least 2 computers. one to run chatserverv2p4, and one to run chatclientv2p1 (p stands for point ie v2p4 is version 2.4) |