I'm writing a chat server application where the users can exchange messages with one of his friends. When the user connects i store his connection on an class variable hash:
@@connections[:user_id] = conn
When someone sends the user a message, I look for his connection on the hash and send the message through it. Sometimes the connection whith the clients simply dies, and the onclose callback is not invoked.