uniwrtc 1.0.3 → 1.0.4
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/client-browser.js +6 -0
- package/demo.html +1 -1
- package/package.json +1 -1
- package/src/room.js +5 -0
package/client-browser.js
CHANGED
|
@@ -125,6 +125,7 @@ class UniWRTCClient {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
sendOffer(offer, targetId) {
|
|
128
|
+
console.log(`[Client] Sending offer to ${targetId}`);
|
|
128
129
|
this.send({
|
|
129
130
|
type: 'offer',
|
|
130
131
|
offer: offer,
|
|
@@ -134,6 +135,7 @@ class UniWRTCClient {
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
sendAnswer(answer, targetId) {
|
|
138
|
+
console.log(`[Client] Sending answer to ${targetId}`);
|
|
137
139
|
this.send({
|
|
138
140
|
type: 'answer',
|
|
139
141
|
answer: answer,
|
|
@@ -143,6 +145,7 @@ class UniWRTCClient {
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
sendIceCandidate(candidate, targetId) {
|
|
148
|
+
console.log(`[Client] Sending ICE candidate to ${targetId}`);
|
|
146
149
|
this.send({
|
|
147
150
|
type: 'ice-candidate',
|
|
148
151
|
candidate: candidate,
|
|
@@ -210,18 +213,21 @@ class UniWRTCClient {
|
|
|
210
213
|
});
|
|
211
214
|
break;
|
|
212
215
|
case 'offer':
|
|
216
|
+
console.log(`[Client] Received offer from ${message.peerId}`);
|
|
213
217
|
this.emit('offer', {
|
|
214
218
|
peerId: message.peerId,
|
|
215
219
|
offer: message.offer
|
|
216
220
|
});
|
|
217
221
|
break;
|
|
218
222
|
case 'answer':
|
|
223
|
+
console.log(`[Client] Received answer from ${message.peerId}`);
|
|
219
224
|
this.emit('answer', {
|
|
220
225
|
peerId: message.peerId,
|
|
221
226
|
answer: message.answer
|
|
222
227
|
});
|
|
223
228
|
break;
|
|
224
229
|
case 'ice-candidate':
|
|
230
|
+
console.log(`[Client] Received ICE candidate from ${message.peerId}`);
|
|
225
231
|
this.emit('ice-candidate', {
|
|
226
232
|
peerId: message.peerId,
|
|
227
233
|
candidate: message.candidate
|
package/demo.html
CHANGED
|
@@ -314,7 +314,7 @@
|
|
|
314
314
|
<p style="color: #999; text-align: center; padding: 20px;">Messages will appear here</p>
|
|
315
315
|
</div>
|
|
316
316
|
<div class="connection-controls" style="margin-bottom: 0;">
|
|
317
|
-
<input type="text" id="chatMessage" placeholder="Type a message..." style="grid-column: 1 / -1;">
|
|
317
|
+
<input type="text" id="chatMessage" placeholder="Type a message..." style="grid-column: 1 / -1;" onkeypress="if(event.key === 'Enter') sendChatMessage()">
|
|
318
318
|
<button class="btn-primary" onclick="sendChatMessage()" style="grid-column: 1 / -1;">Send Message</button>
|
|
319
319
|
</div>
|
|
320
320
|
</div> <div class="card">
|
package/package.json
CHANGED
package/src/room.js
CHANGED
|
@@ -79,10 +79,14 @@ export class Room {
|
|
|
79
79
|
async handleJoin(clientId, message) {
|
|
80
80
|
const { sessionId, peerId } = message;
|
|
81
81
|
|
|
82
|
+
console.log(`[Room] Client ${clientId} joining session ${sessionId}`);
|
|
83
|
+
|
|
82
84
|
// Get list of other peers
|
|
83
85
|
const peers = Array.from(this.clients.keys())
|
|
84
86
|
.filter(id => id !== clientId);
|
|
85
87
|
|
|
88
|
+
console.log(`[Room] Existing peers in session:`, peers);
|
|
89
|
+
|
|
86
90
|
const client = this.clients.get(clientId);
|
|
87
91
|
if (client && client.readyState === WebSocket.OPEN) {
|
|
88
92
|
// Send joined confirmation (align with server schema)
|
|
@@ -95,6 +99,7 @@ export class Room {
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
// Notify other peers
|
|
102
|
+
console.log(`[Room] Broadcasting peer-joined for ${clientId}`);
|
|
98
103
|
this.broadcast({
|
|
99
104
|
type: 'peer-joined',
|
|
100
105
|
sessionId: sessionId,
|