# userLeft

Emitted when a user has left the room.&#x20;

You can discriminate between the **local** user and **remote** users by the `type` field inside the event `data`. The `reason` field tells if user was kicked, the session has ended, or it was just a normal (generic) leave.

#### Sample payload

```json
{
  "type": "userLeft",
  "data": {
    "type": "local",
    "reason": "generic/kicked/sessionEnded",
    "user": {
      "id": "d31ddb8a-07f7-44d0-ba4b-31b5a8e28f68",
      "name": "John Smith",
      ....................
    }   
  }
}
```

#### Sample subscription code

```javascript
sambaFrame.on('userLeft', (event) => {
  const data = event.data;
  if (data.type === 'local') {
     console.log('You have left the room');
  } else {
     console.log(data.user.name, 'has left the room');
  }
});
```
