Currently, I am working on implementing sockets.io in Node.js. I have a class named Rooms with functions that are pretty straightforward. The basic model of the class is as follows:
Room (owner)
this.owner = owner
occupants = []
Room.prototype = {
sendMessage()
getUsers()
leaveParty()
}
However, I am facing a challenge in creating a function to destroy the room itself. I attempted the following code:
Room.prototype.destroy = function() {
this = undefined
}
and then tried executing:
var roomVariable = new Room('blah');
roomVariable.destroy.call(roomVariable);
Unfortunately, this method did not work. I am running out of ideas on how to successfully implement a self-destruct feature for the room. Essentially, I want the room to be erased from memory when there are no more users in the occupants array. Any suggestions would be greatly appreciated. Thank you!