Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7961169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:57:39+00:00 2026-06-04T04:57:39+00:00

Good day, I am having an interesting problem that I cannot understand. I have

  • 0

Good day,

I am having an interesting problem that I cannot understand. I have a class called “HomeScreenManager” which maintains a LinkedList<String> called chat. The HomeScreenManager instance lives on the server and is in charge of keeping track of the connections and the chat log. I then created a class called “ProtocolHomeScreen” which is a class with a LinkedList<String> called chat and implements Serializable. When it comes time to update all the clients with the chat, I want to send out a ProtocolHomeScreen. So I create a brand new instance of the ProtocolHomeScreen and I say that it’s linked list of strings “gets” the HomeScreen’s linked list. So in other words, the linked list that I want to serialize was created in a different class, but I am pointing to it with another instance. The problem is that the data does not get sent, only an empty LinkedList appears on the other side. I’ve done the debugger line by line and inspected all the variables and right before I call writeObject everything appears to be fine, but then on the client side, when I receive the ProtocolHomeScreen instance, the linked list is empty! (its not null though) Any ideas? Thank you!

public class HomeScreenManager implements ObjectMessageHandler, Serializable
{
protected LinkedList<User> users;
protected LinkedList<String> chat;
protected LinkedList<String> sessions;

public HomeScreenManager()
{
    chat = new LinkedList<String>();
    users = new LinkedList<User>();
    sessions = new LinkedList<String>();
}
protected void handleChat(String message)
{
    chat.add(message);

    ProtocolHomeScreen p = new ProtocolHomeScreen(this);

    for(User u:users)
    {
        u.connection.WriteObject(p); //At this point in time, p has the correct data, but when I deserialize p, the chat list is empty...
    }
}

Then here is the protocol class…

public class ProtocolHomeScreen implements Serializable
{
    public LinkedList<String> chat;
    public LinkedList<String> players;
    public LinkedList<String> sessions;


    public ProtocolHomeScreen(HomeScreenManager hms)
    {
        players = new LinkedList<String>();
        for(User u:hms.getUsers())
        {
            players.add(u.getUsername());
        }
        sessions = hms.getSessions();
        chat = hms.getChat();

        chat = new LinkedList<String>();

        for(String s: hms.getChat())
        {
            chat.add(s);
        }

    }

}

Edit

This is the code on the client side… note that the player’s LinkedList comes across just fine, but I think that has something to do with the fact that I created a new instance in the constructor of the ProtocolHomeScreen (on the server side)

else if(obj instanceof ProtocolHomeScreen)
        {       
            ProtocolHomeScreen phs = (ProtocolHomeScreen) obj;

            sessionModel.removeAllElements();
            playersModel.removeAllElements();
            chatOutput.setText("");
            for(String s:phs.players)
                playersModel.addElement(s);

            for(String s:phs.sessions)
                sessionModel.addElement(s); 

            for(String s:phs.chat)
            {
                chatOutput.setText(chatOutput.getText()+s);
            }

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:57:41+00:00Added an answer on June 4, 2026 at 4:57 am

    You need to look at ObjectOutputStream.reset() and why it exists. Any given object is only sent once over an ObjectOutputStream unless you reset() the stream or use writeUnshared().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day everyone. I have been having the same problem all day at work
Good day! I am having a problem in showing the data that I need
Good day, If I have for example the documents which have the following fields
Good day all; I have an UIImageView that I animate around a large UIView.
good day, i am having a bit of a problem here. i am using
Good day, I am having a little bit of a problem. I want to
Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
good day! I am having a problem on showing the updated version of my
Good day everybody, I'm having troubles with the display of a data that does
I am having a problem that has had me stuck for a day and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.