emitting "leaveallrooms" events on undefined

```TypeError: Cannot call method 'emit' of undefined```

raised on my app.

And I have fixed this by checking the exitence of `rm` and emits only when it exists.