You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+37-25
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# SendBird Calls for JavaScript
2
2
3
3
## Introduction
4
-
SendBird Calls is a new product enabling real-time calls between users registered within a SendBird application. SDKs are provided for JavaScript, Android, and iOS. Using any one of these, developers can quickly integrate calling functions into their own applications that will allow users to make and receive internet based real-time voice calls on the SendBird platform.
4
+
`SendBird Calls` is the newest addition to our product portfolio. It enables real-time calls between users within your SendBird application. SDKs are provided for iOS, Android, and JavaScript. Using any one of these, developers can quickly integrate voice and video call functions into their own client apps allowing users to make and receive web-based real-time voice and video calls on the SendBird platform.
5
5
6
6
## Functional Overview
7
-
When implemented, the SendBird Calls SDK provides the framework to both make and receive one-to-one calls, referred to in the SDK as “direct calls” (analogous to “direct messages” / “DMs” in a messaging context). Direct calls are made when a caller identifies a user on the SendBird application and initializes a call request (referred to as dialing). The callee, with the SDK’s event handlers implemented, is notified on all authenticated devices, and can choose to accept the call. If accepted, a network route is established between the caller and callee, and the direct call between the caller and callee begins. Application administrators can then review call logs in the “Calls” section of the SendBird dashboard.
7
+
Our JavaScript SDK for Calls provides the framework to make and receive voice and video calls. Direct calls in the SDK refers to one-to-one calls similar to that of the direct messages (DMs) in messaging services. To make a direct call, the caller should first initialize the call request by dialing to the callee whose all authenticated devices will be notified. The callee then can choose to accept the call from one of the devices. When the call is accepted, a connection is established between the caller and callee, and marks the start of the direct call. SendBird dashboard provides all call logs in the Calls menu for admins to review.
8
8
9
9
## SDK Prerequisites
10
10
* Modern browsers implementing WebRTC APIs are supported; IE isn't supported.
@@ -15,7 +15,7 @@ When implemented, the SendBird Calls SDK provides the framework to both make and
15
15
```
16
16
17
17
## Install and configure the SDK
18
-
Download and install the SDK using npm or yarn.
18
+
Download and install the SDK using `npm` or `yarn`.
19
19
```shell script
20
20
# npm
21
21
npm install sendbird-calls
@@ -43,13 +43,13 @@ or include in header as global variable
43
43
If user dial or accept for the first time in the given domain, browser prompts for permission to use microphone.
44
44
45
45
## Initialize the SendBirdCall instance in a client app
46
-
As shown below, the `SendBirdCall` instance must be initiated when a client app is launched. If another initialization with another APP_ID takes place, all existing data will be deleted and the `SendBirdCall` instance will be initialized with the new APP_ID.
46
+
As shown below, the `SendBirdCall` instance must be initiated when a client app is launched. If another initialization with another `APP_ID` takes place, all existing data will be deleted and the `SendBirdCall` instance will be initialized with the new `APP_ID`.
47
47
```javascript
48
48
SendBirdCall.init(APP_ID);
49
49
```
50
50
51
51
## Authenticate a user and connect websocket to server
52
-
In order to make and receive calls, authenticate the user with SendBird server with the the `SendBirdCall.authenticate()` method. To dial or receive calls, `SendBirdCall` should be connected to websocket server. The socket can be connected by using `SendBirdCall.connectWebSocket()` method.
52
+
In order to make and receive calls, authenticate the user with SendBird server with the the `SendBirdCall.authenticate()` method. To make or receive calls, `SendBirdCall` should be connected to websocket server. Connect socket after authentication has completed using `SendBirdCall.connectWebSocket()` method.
The SDK provides two types of event handlers for various events on your client application: SendBirdCallListener and DirectCallListener.
70
71
71
72
### SendBirdCallListener
72
-
Register a device-specific event handler using the `SendBirdCall.addListener()` method. Before adding the `onRinging()`, a user can't receive an onRinging event. Therefore, it is recommended to add this handler at the beginning of the app. Responding to device-wide events (e.g. incoming calls) is then managed as shown below:
73
+
Register a device-specific event handler using the `SendBirdCall.addListener()` method. Before adding the `onRinging()`, a user can't receive an `onRinging` event. Therefore, it is recommended to add this handler at the beginning of the app. Once the listener is added, responding to device-wide events (for example, incoming calls) is then managed as shown below:
|onRinging() | Invoked when incoming calls are received in the callee’s device. |
86
88
87
89
### DirectCallListener
88
-
Register a call-specific event handler by attaching handler function to the properties of call object directly. Responding to call-specific events (e.g. call connected) is then managed as shown below:
90
+
Register a call-specific event handler by attaching handler function to the properties of call object directly. Responding to call-specific events (for example, call connected) is then managed as shown below:
|onEstablished() |Invoked on the caller’s device and the callee’s device, when the callee has accepted the call by running the method call.accept(), but they are not yet connected to media devices. |
113
-
|onConnected() |Invoked when media devices (e.g microphone, speakers) between the caller and callee are connected and can start the call using media devices. |
114
-
|onEnded() |Invoked when the call has ended on the caller’s device or the callee’s device. This is triggered automatically when either party runs the method call.end() This event listener is also invoked if there are other reasons for ending the call. A table of which can be seen at the bottom. |
115
-
|onRemoteAudioEnabled() |Invoked on the caller’s devices when the callee changes their audio settings. |
114
+
|onEstablished() |On the caller’s device and the callee’s device, the callee has accepted the call by running the method call.accept(), but they are not yet connected to media devices. |
115
+
|onConnected() |Media devices (for example, microphone and speakers) between the caller and callee are connected and can start the call using media devices. |
116
+
|onEnded() |The call has ended on the caller’s device or the callee’s device. This is triggered automatically when either party runs the method call.end(). This event listener is also invoked if there are other reasons for ending the call. A table of which can be seen at the bottom. |
117
+
|onRemoteAudioEnabled() |On the caller’s devices, the callee changes their audio settings. |
116
118
117
119
## Make a call
118
-
Initiate a call by providing the callee’s user id into the `SendBirdCall.dial()` method. Use the `callOption` object to choose initial call configuration (e.g. muted/unmuted)
120
+
Initiate a call by providing the callee’s user id into the `SendBirdCall.dial()` method. Use the `callOption` object to choose initial call configuration (for example, muted/unmuted)
Receive incoming calls by registering handler object. Accept or decline incoming calls using the `directCall.accept()` or the `directCall.end()` methods.
157
+
Receive incoming calls by registering the event handler. Accept or decline incoming calls using the `directCall.accept()` or the `directCall.end()` methods.
155
158
156
-
If the call is accepted, a media session will be established by the SDK.
159
+
If the call is accepted, a media session will automatically be established by the SDK.
157
160
158
-
Event handlers muse be registered before accepting a call. Once registered, this listeners enable reacting to mid-call events via callbacks methods.
161
+
The event handler muse be registered before accepting a call. Once registered, the listeners enable reacting to mid-call events via callbacks methods.
Incoming calls are received via the application's persistent internal server connection, which is established in `SendBirdCall.connectWebSocket()`.
193
197
194
198
## Handle a current call
195
-
196
199
While a call is in progress, mute or unmute the caller’s audio using the `directCall.mute()` or `directCall.unmute()` method(s). If the callee changes their audio settings, the caller is notified via the `directCall.onRemoteAudioEnabled` listener.
197
200
198
201
```javascript
@@ -204,28 +207,34 @@ call.unmute();
204
207
205
208
// receives the event
206
209
call.onRemoteAudioEnabled= (call) => {
207
-
...
210
+
if (call.isRemoteAudioEnabled) {
211
+
// The peer has been muted.
212
+
// Consider displaying an unmuted icon.
213
+
} else {
214
+
// The peer has been muted.
215
+
// Consider displaying and toggling a muted icon.
216
+
}
208
217
}
209
218
```
210
219
211
220
## End a call
212
-
A caller ends using the `directCall.end()` method. The event can be processed via the `directCall.onEnded()` listener. This listener is also called/fired when the callee ends call.
221
+
A caller can end a call using the `directCall.end()` method. The event can be processed via the `directCall.onEnded()` listener. The listener is also called/fired when the callee ends the call.
213
222
214
223
```javascript
215
224
// End a call
216
225
call.end();
217
226
218
227
// receives the event
219
228
call.onEnded= (call) => {
220
-
...
229
+
// Consider releasing or destroying call-related view from here.
221
230
};
222
231
```
223
232
224
233
## Retrieve a call information
225
234
The local or remote user’s information is available via the `directCall.localUser` and `directCall.remoteUser` properties.
226
235
227
236
## Retrieve call history
228
-
SendBird’s servers automatically store details of calls. These details can be used later to display a call history for users. A user’s call history is available via a `DirectCallLogListQuery` instance.
237
+
SendBird servers automatically store details of calls, which can be used later to display a call history for users. A user’s call history is available via a `DirectCallLogListQuery` instance.
|next() | Used to query call history from SendBirdCall server. |
264
+
|next() | Used to query call history from `SendBirdCall` server. |
253
265
|hasNext | If true, there is more call history to be retrieved. |
254
266
|isLoading | If true, call history is being retrieved from SendBirdCall server. |
255
267
|params.limit | Specifies the number of call logs to return at once. |
256
-
|params.myRole | Returns call logs of the specified role. For example, if myRole is 'dc_callee', query will return only the callee’s call logs. |
257
-
|params.endResults | Returns the call logs for specified results. If you specify more than one result, they are processed as OR condition and all call logs corresponding with the specified end results will be returned. For example, if endResults is ['NO_ANSWER', 'CANCELED'], only the NO_ANSWER and CANCELED call logs will be returned.|
268
+
|params.myRole | Returns call logs of the specified role. For example, if myRole is `'dc_callee'`, query will return only the callee’s call logs. |
269
+
|params.endResults | Returns the call logs for specified results. If you specify more than one result, they are processed as `OR` condition and all call logs corresponding with the specified end results will be returned. For example, if endResults is `['NO_ANSWER', 'CANCELED']`, only the `NO_ANSWER` and `CANCELED` call logs will be returned.|
258
270
259
271
## Additional information: call results
260
272
To access the additional information relating to why a call ended, consider that you can get `directCall.endResult` property whenever needed. However, it would be most relevant perhaps, to call it within the `onEnded()` callback.
0 commit comments