@voicemaster/core 1.0.7 → 1.0.8

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.
package/dist/index.js CHANGED
@@ -148,23 +148,36 @@ var VoiceClient = class {
148
148
  });
149
149
  }
150
150
  async handleOffer(message) {
151
- const offer = new RTCSessionDescription(message.sdp);
152
- await this.pc.setRemoteDescription(offer);
153
- const answer = await this.pc.createAnswer();
154
- await this.pc.setLocalDescription(answer);
155
- this.send({
156
- type: "answer",
157
- sdp: this.pc.localDescription
158
- });
151
+ try {
152
+ console.log("Handling offer", message);
153
+ const offer = new RTCSessionDescription(message.sdp);
154
+ await this.pc.setRemoteDescription(offer);
155
+ console.log("Remote description set");
156
+ const answer = await this.pc.createAnswer();
157
+ console.log("Answer created");
158
+ await this.pc.setLocalDescription(answer);
159
+ console.log("Local description set");
160
+ this.send({
161
+ type: "answer",
162
+ sdp: this.pc.localDescription
163
+ });
164
+ } catch (err) {
165
+ console.error("Offer handling error:", err);
166
+ }
159
167
  }
160
168
  async handleAnswer(message) {
161
169
  const answer = new RTCSessionDescription(message.sdp);
162
170
  await this.pc.setRemoteDescription(answer);
163
171
  }
164
172
  async handleCandidate(message) {
165
- if (message.candidate) {
166
- const candidate = new RTCIceCandidate(message.candidate);
167
- await this.pc.addIceCandidate(candidate);
173
+ try {
174
+ if (message.candidate) {
175
+ const candidate = new RTCIceCandidate(message.candidate);
176
+ await this.pc.addIceCandidate(candidate);
177
+ console.log("ICE candidate added");
178
+ }
179
+ } catch (err) {
180
+ console.error("Candidate error:", err);
168
181
  }
169
182
  }
170
183
  send(data) {
package/dist/index.mjs CHANGED
@@ -122,23 +122,36 @@ var VoiceClient = class {
122
122
  });
123
123
  }
124
124
  async handleOffer(message) {
125
- const offer = new RTCSessionDescription(message.sdp);
126
- await this.pc.setRemoteDescription(offer);
127
- const answer = await this.pc.createAnswer();
128
- await this.pc.setLocalDescription(answer);
129
- this.send({
130
- type: "answer",
131
- sdp: this.pc.localDescription
132
- });
125
+ try {
126
+ console.log("Handling offer", message);
127
+ const offer = new RTCSessionDescription(message.sdp);
128
+ await this.pc.setRemoteDescription(offer);
129
+ console.log("Remote description set");
130
+ const answer = await this.pc.createAnswer();
131
+ console.log("Answer created");
132
+ await this.pc.setLocalDescription(answer);
133
+ console.log("Local description set");
134
+ this.send({
135
+ type: "answer",
136
+ sdp: this.pc.localDescription
137
+ });
138
+ } catch (err) {
139
+ console.error("Offer handling error:", err);
140
+ }
133
141
  }
134
142
  async handleAnswer(message) {
135
143
  const answer = new RTCSessionDescription(message.sdp);
136
144
  await this.pc.setRemoteDescription(answer);
137
145
  }
138
146
  async handleCandidate(message) {
139
- if (message.candidate) {
140
- const candidate = new RTCIceCandidate(message.candidate);
141
- await this.pc.addIceCandidate(candidate);
147
+ try {
148
+ if (message.candidate) {
149
+ const candidate = new RTCIceCandidate(message.candidate);
150
+ await this.pc.addIceCandidate(candidate);
151
+ console.log("ICE candidate added");
152
+ }
153
+ } catch (err) {
154
+ console.error("Candidate error:", err);
142
155
  }
143
156
  }
144
157
  send(data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicemaster/core",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "WebRTC voice communication core library",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -39,6 +39,8 @@ export class VoiceClient {
39
39
  this.eventHandlers.get(event)!.push(callback);
40
40
  }
41
41
 
42
+
43
+
42
44
  private emit(event: string, ...args: any[]): void {
43
45
  const handlers = this.eventHandlers.get(event);
44
46
  if (handlers) {
@@ -151,14 +153,25 @@ export class VoiceClient {
151
153
  }
152
154
 
153
155
  private async handleOffer(message: any): Promise<void> {
154
- const offer = new RTCSessionDescription(message.sdp);
155
- await this.pc!.setRemoteDescription(offer);
156
- const answer = await this.pc!.createAnswer();
157
- await this.pc!.setLocalDescription(answer);
158
- this.send({
159
- type: 'answer',
160
- sdp: this.pc!.localDescription
161
- });
156
+ try {
157
+ console.log('Handling offer', message);
158
+ const offer = new RTCSessionDescription(message.sdp);
159
+ await this.pc!.setRemoteDescription(offer);
160
+ console.log('Remote description set');
161
+
162
+ const answer = await this.pc!.createAnswer();
163
+ console.log('Answer created');
164
+
165
+ await this.pc!.setLocalDescription(answer);
166
+ console.log('Local description set');
167
+
168
+ this.send({
169
+ type: 'answer',
170
+ sdp: this.pc!.localDescription
171
+ });
172
+ } catch (err) {
173
+ console.error('Offer handling error:', err);
174
+ }
162
175
  }
163
176
 
164
177
  private async handleAnswer(message: any): Promise<void> {
@@ -167,9 +180,14 @@ export class VoiceClient {
167
180
  }
168
181
 
169
182
  private async handleCandidate(message: any): Promise<void> {
170
- if (message.candidate) {
171
- const candidate = new RTCIceCandidate(message.candidate);
172
- await this.pc!.addIceCandidate(candidate);
183
+ try {
184
+ if (message.candidate) {
185
+ const candidate = new RTCIceCandidate(message.candidate);
186
+ await this.pc!.addIceCandidate(candidate);
187
+ console.log('ICE candidate added');
188
+ }
189
+ } catch (err) {
190
+ console.error('Candidate error:', err);
173
191
  }
174
192
  }
175
193