@eleven-am/pondsocket 0.1.32 → 0.1.33
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/channel.js +11 -4
- package/package.json +1 -1
package/client/channel.js
CHANGED
|
@@ -171,11 +171,11 @@ class Channel {
|
|
|
171
171
|
this._publish(message);
|
|
172
172
|
}
|
|
173
173
|
_publish(data) {
|
|
174
|
-
if (
|
|
175
|
-
this.
|
|
174
|
+
if (this._joinState.value && this._clientState.value !== 'OPEN') {
|
|
175
|
+
this._publisher(data);
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
|
-
this.
|
|
178
|
+
this._queue.push(data);
|
|
179
179
|
}
|
|
180
180
|
_subscribeToPresence(callback) {
|
|
181
181
|
return this._receiver.subscribe((data) => {
|
|
@@ -187,11 +187,14 @@ class Channel {
|
|
|
187
187
|
_init(receiver) {
|
|
188
188
|
const unsubMessages = receiver.subscribe((data) => {
|
|
189
189
|
if (data.channelName === this._name) {
|
|
190
|
+
if (!this._joinState.value) {
|
|
191
|
+
this._joinState.publish(true);
|
|
192
|
+
}
|
|
190
193
|
this._receiver.publish(data);
|
|
191
194
|
}
|
|
192
195
|
});
|
|
193
196
|
const unsubStateChange = this._clientState.subscribe((state) => {
|
|
194
|
-
if (state === 'OPEN') {
|
|
197
|
+
if (state === 'OPEN' && this._queue.length > 0) {
|
|
195
198
|
const joinMessage = {
|
|
196
199
|
action: enums_1.ClientActions.JOIN_CHANNEL,
|
|
197
200
|
channelName: this._name,
|
|
@@ -202,8 +205,12 @@ class Channel {
|
|
|
202
205
|
this._queue.forEach((message) => {
|
|
203
206
|
this._publisher(message);
|
|
204
207
|
});
|
|
208
|
+
this._joinState.publish(true);
|
|
205
209
|
this._queue = [];
|
|
206
210
|
}
|
|
211
|
+
else if (state !== 'OPEN') {
|
|
212
|
+
this._joinState.publish(false);
|
|
213
|
+
}
|
|
207
214
|
});
|
|
208
215
|
const unsubPresence = this._subscribeToPresence((_, payload) => {
|
|
209
216
|
this._presence = payload.presence;
|