# Start, Join, Leave Meetings

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

APIs to start, join, and leave meetings are described in `IMeetingService.h.`
You must implement the `IMeetingServiceSink` to receive callbacks. In many cases, your API call will command the Zoom Room to take action, but the results may not be available immediately and will be communicated via a callback.

```cpp
// get the meeting service
IMeetingService* pMeetingService = pRoomService->GetMeetingService();
// implement the meeting service sink to receive callbacks.
IMeetingServiceSink *pMeetingServiceSink = new AutoIMeetingServiceSink();
pMeetingService->RegisterSink(pMeetingServiceSink);
```

## Start a Meeting

Call `IMeetingService::StartInstantMeeting` to start an instant meeting. Check the `ZRCSDKError`. If it is `ZRCSDKERR_SUCCESS`, the API call has been sent to the Zoom Room successfully. The start meeting action will be further handled by the Zoom Rooms application.

```cpp
ZRCSDKError sdkErr = pMeetingService->StartInstantMeeting();
if (sdkErr == ZRCSDKERR_SUCCESS)
{
    // The request was successfully sent to the Zoom Room.
    // The Zoom Room will further handle the StartInstantMeeting Action.
    // Further updates will come via callback.
}
```

## Join a Meeting

Call `IMeetingService::JoinMeeting` with the meeting number to join a meeting. Check the `ZRCSDKError`. If it is `ZRCSDKERR_SUCCESS`, the API call has been sent to the Zoom Room successfully. The join meeting action will be further handled by the Zoom Rooms application.

```cpp
ZRCSDKError sdkErr = pMeetingService->JoinMeeting(strMeetingNumber);
if (sdkErr == ZRCSDKERR_SUCCESS)
{
    // The request was successfully sent to the Zoom Room.
    // The Zoom Room will further handle the JoinMeeting Action.
    // Further updates will come via callback.
}
```

## Get the Start or Join Meeting Status

-   Check `MeetingStatus` in `IMeetingServiceSink::OnUpdateMeetingStatus`.
-   Start or join meeting may take several seconds to complete.
    -   When your application receives the `IMeetingServiceSink::OnConfReadyNotification` callback, the Zoom Room has successfully started or joined a meeting.
    -   When the start or join meeting commands fail, you will receive a notification via `IMeetingServiceSink::OnMeetingErrorNotification`. This notification will include the error code and the error description.

## Leave a Meeting

Call `IMeetingService::ExitMeeting` to leave or end a meeting.

```cpp
// Leave meeting command: ExitMeetingCmdLeave
// End meeting command: ExitMeetingCmdEnd. The Zoom Room must be the host to end.
ZRCSDKError sdkErr = pMeetingService->ExitMeeting(ExitMeetingCmdLeave);
if (sdkErr == ZRCSDKERR_SUCCESS)
{
    // The request was successfully sent to the Zoom Room.
    // The Zoom Room will further handle the ExitMeeting Action.
    // Further updates will come via callback.
}
```

## Fail to Start or Join Meeting

If you fail to start or join a meeting, you will receive `IMeetingServiceSink::OnMeetingErrorNotification` to notify the error reason.

```json
// For example, if your meeting number is invalid with JoinMeeting API
// You will receive a OnMeetingErrorNotification
{
    "command": "OnMeetingErrorNotification",
    "paras": [
        {
            "errorCode": 0,
            "errorDescLink": "",
            "errorInfo": "This meeting ID is not valid. Please check and try again.",
            "errorTitle": ""
        }
    ],
    "service": "IMeetingServiceSink"
}
```
