Page 3 of 3 FirstFirst 123
Results 41 to 60 of 60
Like Tree2Likes

Thread: How update Jlist in java Chat

  1. #41
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Yes, and which client(s) receive what is written to that outputstream?

  2. #42
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    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() ); //<--------------------

  3. #43
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    which client(s) receive what is written to that outputstream?
    I know there is one client that does, the question is:
    How many clients receive any messages when the server sends a message?

    Look at the my print out again.

  4. #44
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    i am am intending it for every client that connects but appearantly just one reads it..

  5. #45
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    i am am intending it for every client that connects
    You must see what the program is really doing.
    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.

  6. #46
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    all of them

  7. #47
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    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.

  8. #48
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    actually, only one client sees the message.

  9. #49
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    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.
    pappyj77 likes this.

  10. #50
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    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);

  11. #51
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    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.
    pappyj77 likes this.

  12. #52
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    should this be taking me back to the for loop?

  13. #53
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    the variable name is output if thats the question you are asking

  14. #54
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    thank you MR Norm... u've been great help.. am just knida dumb obviously

  15. #55
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Glad you figured it out.

  16. #56
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    i havnt yet, but i will eventually, i'll just keep struggling with it. cos i know u have given every clew available...

  17. #57
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    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?

  18. #58
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default

    given up, tnx..

  19. #59
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    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.

  20. #60
    pappyj77 is offline Member
    Join Date
    Jul 2011
    Location
    kent, UK
    Posts
    47
    Rep Power
    0

    Default 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..

Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 4
    Last Post: 03-31-2011, 10:37 PM
  2. Replies: 2
    Last Post: 03-21-2010, 02:31 PM
  3. Cannot get my JList to update!
    By rangvald in forum AWT / Swing
    Replies: 1
    Last Post: 11-17-2009, 01:57 PM
  4. Help with Java IRC Chat Channel
    By sari in forum New To Java
    Replies: 1
    Last Post: 02-03-2009, 07:21 AM
  5. Java Program chat
    By susan in forum Advanced Java
    Replies: 1
    Last Post: 07-25-2007, 09:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •