fixing leaveRoom bug, and emitting events for joining and leaving rooms