@voicemaster/core 1.0.6 → 1.0.7
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -6
- package/dist/index.mjs +3 -6
- package/package.json +1 -1
- package/src/VoiceClient.ts +3 -6
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var VoiceClient = class {
|
|
|
33
33
|
this.remoteStream = null;
|
|
34
34
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
35
35
|
this.isConnectedFlag = false;
|
|
36
|
+
this.targetUserId = null;
|
|
36
37
|
this.signalingUrl = config.signalingUrl;
|
|
37
38
|
this.roomId = config.roomId;
|
|
38
39
|
this.userId = config.userId;
|
|
@@ -82,10 +83,6 @@ var VoiceClient = class {
|
|
|
82
83
|
this.pc.ontrack = (event) => {
|
|
83
84
|
this.remoteStream = event.streams[0];
|
|
84
85
|
this.emit("remoteStream", this.remoteStream);
|
|
85
|
-
if (!this.isConnectedFlag) {
|
|
86
|
-
this.isConnectedFlag = true;
|
|
87
|
-
this.emit("connected");
|
|
88
|
-
}
|
|
89
86
|
};
|
|
90
87
|
this.pc.onicecandidate = (event) => {
|
|
91
88
|
if (event.candidate) {
|
|
@@ -101,8 +98,6 @@ var VoiceClient = class {
|
|
|
101
98
|
this.isConnectedFlag = true;
|
|
102
99
|
this.emit("connected");
|
|
103
100
|
}
|
|
104
|
-
} else if (this.pc?.connectionState === "disconnected") {
|
|
105
|
-
this.emit("disconnected");
|
|
106
101
|
}
|
|
107
102
|
};
|
|
108
103
|
}
|
|
@@ -124,11 +119,13 @@ var VoiceClient = class {
|
|
|
124
119
|
switch (message.type) {
|
|
125
120
|
case "user-joined":
|
|
126
121
|
if (message.userId !== this.userId) {
|
|
122
|
+
this.targetUserId = message.userId;
|
|
127
123
|
await this.createOffer();
|
|
128
124
|
this.emit("userJoined", message.userId);
|
|
129
125
|
}
|
|
130
126
|
break;
|
|
131
127
|
case "offer":
|
|
128
|
+
this.targetUserId = message.userId;
|
|
132
129
|
await this.handleOffer(message);
|
|
133
130
|
break;
|
|
134
131
|
case "answer":
|
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ var VoiceClient = class {
|
|
|
7
7
|
this.remoteStream = null;
|
|
8
8
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
9
9
|
this.isConnectedFlag = false;
|
|
10
|
+
this.targetUserId = null;
|
|
10
11
|
this.signalingUrl = config.signalingUrl;
|
|
11
12
|
this.roomId = config.roomId;
|
|
12
13
|
this.userId = config.userId;
|
|
@@ -56,10 +57,6 @@ var VoiceClient = class {
|
|
|
56
57
|
this.pc.ontrack = (event) => {
|
|
57
58
|
this.remoteStream = event.streams[0];
|
|
58
59
|
this.emit("remoteStream", this.remoteStream);
|
|
59
|
-
if (!this.isConnectedFlag) {
|
|
60
|
-
this.isConnectedFlag = true;
|
|
61
|
-
this.emit("connected");
|
|
62
|
-
}
|
|
63
60
|
};
|
|
64
61
|
this.pc.onicecandidate = (event) => {
|
|
65
62
|
if (event.candidate) {
|
|
@@ -75,8 +72,6 @@ var VoiceClient = class {
|
|
|
75
72
|
this.isConnectedFlag = true;
|
|
76
73
|
this.emit("connected");
|
|
77
74
|
}
|
|
78
|
-
} else if (this.pc?.connectionState === "disconnected") {
|
|
79
|
-
this.emit("disconnected");
|
|
80
75
|
}
|
|
81
76
|
};
|
|
82
77
|
}
|
|
@@ -98,11 +93,13 @@ var VoiceClient = class {
|
|
|
98
93
|
switch (message.type) {
|
|
99
94
|
case "user-joined":
|
|
100
95
|
if (message.userId !== this.userId) {
|
|
96
|
+
this.targetUserId = message.userId;
|
|
101
97
|
await this.createOffer();
|
|
102
98
|
this.emit("userJoined", message.userId);
|
|
103
99
|
}
|
|
104
100
|
break;
|
|
105
101
|
case "offer":
|
|
102
|
+
this.targetUserId = message.userId;
|
|
106
103
|
await this.handleOffer(message);
|
|
107
104
|
break;
|
|
108
105
|
case "answer":
|
package/package.json
CHANGED
package/src/VoiceClient.ts
CHANGED
|
@@ -17,6 +17,7 @@ export class VoiceClient {
|
|
|
17
17
|
private userId: string;
|
|
18
18
|
private iceServers: RTCIceServer[];
|
|
19
19
|
private isConnectedFlag = false;
|
|
20
|
+
private targetUserId: string | null = null;
|
|
20
21
|
|
|
21
22
|
constructor(config: VoiceClientConfig) {
|
|
22
23
|
this.signalingUrl = config.signalingUrl;
|
|
@@ -76,10 +77,6 @@ export class VoiceClient {
|
|
|
76
77
|
this.pc.ontrack = (event) => {
|
|
77
78
|
this.remoteStream = event.streams[0];
|
|
78
79
|
this.emit('remoteStream', this.remoteStream);
|
|
79
|
-
if (!this.isConnectedFlag) {
|
|
80
|
-
this.isConnectedFlag = true;
|
|
81
|
-
this.emit('connected');
|
|
82
|
-
}
|
|
83
80
|
};
|
|
84
81
|
|
|
85
82
|
this.pc.onicecandidate = (event) => {
|
|
@@ -97,8 +94,6 @@ export class VoiceClient {
|
|
|
97
94
|
this.isConnectedFlag = true;
|
|
98
95
|
this.emit('connected');
|
|
99
96
|
}
|
|
100
|
-
} else if (this.pc?.connectionState === 'disconnected') {
|
|
101
|
-
this.emit('disconnected');
|
|
102
97
|
}
|
|
103
98
|
};
|
|
104
99
|
}
|
|
@@ -125,11 +120,13 @@ export class VoiceClient {
|
|
|
125
120
|
switch (message.type) {
|
|
126
121
|
case 'user-joined':
|
|
127
122
|
if (message.userId !== this.userId) {
|
|
123
|
+
this.targetUserId = message.userId;
|
|
128
124
|
await this.createOffer();
|
|
129
125
|
this.emit('userJoined', message.userId);
|
|
130
126
|
}
|
|
131
127
|
break;
|
|
132
128
|
case 'offer':
|
|
129
|
+
this.targetUserId = message.userId;
|
|
133
130
|
await this.handleOffer(message);
|
|
134
131
|
break;
|
|
135
132
|
case 'answer':
|