In my script I read messages from socket and change the state of some objects in memory depending on the content in message. Everything works fine.
But I want to implement deletion of non-active objects: for example, if there's no message for specified object during some time, it should be deleted. What is the best way to do it ?
Store a timestamp in each object - update the timestamp to the current time whenever you modify it.
Then have something that runs every so often, looks at all of the objects, and removes any with a timestamp earlier than a certain amount before the current time.
How to track an objects state in time?