I have the following code. In the onClientClose method I want to remove the _socketServicer instance from the _clientSockets array if it is closed. How do I reference the _socketServicer instance in the array if I don't know its index?
public function connectHandler(event:ServerSocketConnectEvent):void { _socketServicer=new SocketService(event.socket, this,log);
_socketServicer.addEventListener(Event.CLOSE, onClientClose);
_clientSockets.push(_socketServicer); //maintain a reference to prevent premature garbage collection
}
private function onClientClose(event:Event):void {
//Nullify references to closed sockets
for each (var servicer:SocketService in _clientSockets) {
if (servicer.closed)
servicer=null;
}
}