I’m trying to make a simple chat server in Java. Now I have a thread that accepts the tcp-ip connections, ads users, removes users and add comments.
I would like to erase any users who where on for x amount of time and had no contact with the chat server. I was going to have a separate thread, that would be in a different class do this.
The problem is that the thread that accepts the connections contains a class called cUser to handle the users, and the class for doing the time out would not see this class.
In c i could just have a global. I was thinking about making the cUser class members all static, seems a little messy.
Is there a clean way to do this?
Ted
If accessing the class is your main concern, then moving it into a separate file and delcaring the class public is one option.
Or you can have call back methods on the main class to be able to communicate with your inner class