• Post Reply Bookmark Topic Watch Topic
  • New Topic

Chat room  RSS feed

 
Audie
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a simple Cleint-Server chatroom using a simple socket without RMI. I am running this on one computer and opening several instances of the JVM. My client has two threads one for input and one for output. The server has only one thread. This is run in the dos prompt. I am only able to respond to the client that sent a message and none of the others. Can anyone layout the basic architecture, obviously I'm missing something.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Audie -
Please change your name to conform to JavaRanch's naming policy.
In a chat room application, each client will have to connect via its own socket pair, but to a shared server object. The server object can supply a method any client can call at any time (i.e., poll it) to get new messages. This is very easy to to do -- just call a remotely supported method like getMessages() every 5 seconds or whatever.
The next step -- getting the server to send messages back to the client only when they occur -- is a little more difficult conceptually. You should get a polling strategy to work first, then consider an "event-driven" one.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!