Results 41 to 60 of 60
Thread: How update Jlist in java Chat
- 08-26-2011, 12:39 AM #41
- 08-26-2011, 12:50 AM #42
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
in Clients handShake()
Java Code:private void handShake() throws IOException { String message; String value[]; value = new String [100]; try { output.writeObject(Client_name); output.flush(); input = new ObjectInputStream(client.getInputStream() ); //<--------------------
- 08-26-2011, 01:10 AM #43
I know there is one client that does, the question is:which client(s) receive what is written to that outputstream?
How many clients receive any messages when the server sends a message?
Look at the my print out again.
- 08-26-2011, 01:32 AM #44
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
i am am intending it for every client that connects but appearantly just one reads it..
- 08-26-2011, 01:56 AM #45
You must see what the program is really doing.i am am intending it for every client that connects
Do you understand my question?
How many clients receive any messages when the server sends a message?
The answers could be:
only one
the last two
all of them
Chose one of the above.
- 08-26-2011, 02:02 AM #46
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
all of them
- 08-26-2011, 02:31 AM #47
Can you show that by adding print outs to the client class that shows that it has received a message?
Then start more than one client and see if the all of them receive all of the messages that the server sends.
If you look at my posted print outs you will see what I saw when I ran the above test.
- 08-26-2011, 02:46 AM #48
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
actually, only one client sees the message.
- 08-26-2011, 02:49 AM #49
Yes, that is what I think.
The question now is: Why does only one client get any messages?
And why only the last client?
That sounds like a variable is being written over with the value that 'points' to only the last client. The value for the previous clients is gone.
- 08-26-2011, 03:33 AM #50
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
i have removed the what seemed to be over writing the dat, but am getting continious loop of the message
Java Code:while ( !message.equals( "." ) ){ value[i++] =message; //message = (String) input.readObject(); userList.setListData(value);
- 08-26-2011, 03:36 AM #51
What variable has the reference for the outputstream used to send to the client? That variable 'points' to the last client that has connected. The previous value in that variable was overwritten and lost.
- 08-26-2011, 03:56 AM #52
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
should this be taking me back to the for loop?
- 08-26-2011, 04:07 AM #53
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
the variable name is output if thats the question you are asking
- 08-26-2011, 04:40 AM #54
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
thank you MR Norm... u've been great help.. am just knida dumb obviously
.gif)
- 08-26-2011, 01:36 PM #55
Glad you figured it out.
- 08-26-2011, 02:38 PM #56
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
i havnt yet, but i will eventually, i'll just keep struggling with it. cos i know u have given every clew available...
- 08-26-2011, 03:08 PM #57
Have you considered keeping a list of connections, one for each client, so that you can communicate with each of them, not just the last one to connect?
- 08-26-2011, 09:10 PM #58
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
given up, tnx..
- 08-26-2011, 09:18 PM #59
Strange. You know how to save objects in the clientList array and send all of its contents to one client.
How about saving the values of the output object in an array and use the contents of that array to be able to send messages to each of the clients. You'd need a nested loop. Outer loop gets the value of output to use to send a message to the next client. Inner loop sends the messages from the clientList array to that client.
- 09-13-2011, 01:26 AM #60
Member
- Join Date
- Jul 2011
- Location
- kent, UK
- Posts
- 47
- Rep Power
- 0
Re: How update Jlist in java Chat
hi eventually Got what u have been saying, but i had to make alot of changes. thank you, but now i have a different problem :). kind of related but i tried all i could as wel but theres just something am not doing right and probably which i dont know. i dont know if i should open a new thread edit this one, however since you are not online, i will open a new thread. thank you very much..
Similar Threads
-
Voice chat with multiple chat rooms, suggestions needed
By sonofrage in forum NetworkingReplies: 4Last Post: 03-31-2011, 10:37 PM -
I have created a Java Chat Server, now where do i put it?
By lorenz82 in forum New To JavaReplies: 2Last Post: 03-21-2010, 02:31 PM -
Cannot get my JList to update!
By rangvald in forum AWT / SwingReplies: 1Last Post: 11-17-2009, 01:57 PM -
Help with Java IRC Chat Channel
By sari in forum New To JavaReplies: 1Last Post: 02-03-2009, 07:21 AM -
Java Program chat
By susan in forum Advanced JavaReplies: 1Last Post: 07-25-2007, 09:05 PM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks