sceyt-call 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +63 -0
  2. package/index.d.ts +799 -805
  3. package/index.js +1908 -1371
  4. package/package.json +3 -16
package/README.md CHANGED
@@ -9,6 +9,7 @@ JavaScript SDK for real-time voice and video calls with WebRTC. This SDK works a
9
9
  * [Quick Start](#quick-start)
10
10
  * [Media Flow Types](#media-flow-types)
11
11
  * [Call Methods](#call-methods)
12
+ * [Error Handling](#error-handling)
12
13
  * [Call Events](#call-events)
13
14
  * [Client Events](#client-events)
14
15
  * [Call Management](#call-management)
@@ -108,6 +109,68 @@ await call.addParticipants(['user3', 'user4']);
108
109
  await call.switchToSFU(); // Upgrade P2P to SFU
109
110
  ```
110
111
 
112
+ ## Error Handling
113
+
114
+ All methods return `CallClientResult<T>` with structured error information instead of throwing exceptions:
115
+
116
+ ### Pattern 1: Check Result Success
117
+
118
+ ```typescript
119
+ const result = await call.enableVideo(true);
120
+ if (!result.success) {
121
+ console.error('Error:', result.error?.message);
122
+ console.error('Code:', result.error?.code);
123
+ }
124
+ ```
125
+
126
+ ### Pattern 2: Use Error Callback
127
+
128
+ Some methods support optional error callbacks for real-time error feedback:
129
+
130
+ ```typescript
131
+ const handleError = (result) => {
132
+ if (result.error) {
133
+ console.error(result.error.message);
134
+ }
135
+ };
136
+
137
+ // Methods with error callback support:
138
+ const joinResult = callClient.join(options, handleError); // error callback
139
+ callClient.reject(call, reason, handleError); // error callback
140
+ const videoResult = await call.enableVideo(true, handleError); // error callback
141
+ await call.startScreenShare(handleError); // error callback
142
+ await call.stopScreenShare(handleError); // error callback
143
+ call.mute(true, handleError); // error callback
144
+ await call.switchToSFU(handleError); // error callback
145
+ ```
146
+
147
+ **Methods Supporting Error Callbacks:**
148
+ - `callClient.join(options, errorCallback?)` - Called on join errors
149
+ - `callClient.reject(call, reason?, errorCallback?)` - Called on reject errors
150
+ - `callClient.leave(call)` - No callback (check result instead)
151
+ - `call.enableVideo(enabled, errorCallback?)` - Called on video/camera errors
152
+ - `call.startScreenShare(errorCallback?)` - Called on screen share errors
153
+ - `call.stopScreenShare(errorCallback?)` - Called on stop errors
154
+ - `call.mute(mute, errorCallback?)` - Called on mute errors
155
+ - `call.switchToSFU(errorCallback?)` - Called on SFU switch errors
156
+
157
+ **All Error Codes:**
158
+
159
+ | Code | Error Type | Cause | Solution |
160
+ |------|-----------|-------|----------|
161
+ | 4000 | `BadSignal` | Invalid signal format | Check signal parameters |
162
+ | 4001 | `CallNotFound` | Call not found in system | Verify call ID exists |
163
+ | 4002 | `ParticipantNotFound` | Participant not in call | Check participant exists |
164
+ | 4003 | `NotAllowed` | Operation not allowed in state | Verify call state |
165
+ | 4004 | `ParticipantAlreadyExists` | Participant already in call | Don't add duplicates |
166
+ | 4005 | `NotAllowed` | Permission denied by user | Enable in browser settings |
167
+ | 4006 | `BadRequest` | Invalid request parameters | Fix parameters |
168
+ | 5001 | `InternalError` | Server-side error | Retry (resendable) |
169
+ | 9901 | `NetworkError` | Network connectivity lost | Check connection (resendable) |
170
+ | 9902 | `Timeout` | Operation timed out | Retry (resendable) |
171
+ | 9903 | `NetworkError` | Network error occurred | Check connection (resendable) |
172
+ | 9904 | `NetworkError` | Network error occurred | Check connection (resendable) |
173
+
111
174
  ## Call Events
112
175
 
113
176
  ```typescript