Skip to content

Commit c15bc7b

Browse files
committed
修复再次订阅无效问题
1 parent d1a904c commit c15bc7b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/push.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ Push.prototype.createConnection = function () {
6161
clearTimeout(_this.pingTimeoutTimer);
6262
_this.pingTimeoutTimer = 0;
6363
}
64-
64+
6565
params = JSON.parse(params.data);
6666
var event = params.event;
6767
var channel_name = params.channel;
68-
68+
6969
if (event === 'pusher:pong') {
7070
_this.checkoutPing();
7171
return;
@@ -158,6 +158,7 @@ function createChannel(channel_name, push)
158158
channel.subscribeCb = function () {
159159
push.connection.send(JSON.stringify({event:"pusher:subscribe", data:{channel:channel_name}}));
160160
}
161+
channel.processSubscribe();
161162
return channel;
162163
}
163164

@@ -341,16 +342,16 @@ var __extends = (this && this.__extends) || function (d, b) {
341342

342343
function Channel(connection, channel_name) {
343344
this.subscribed = false;
344-
this.dispatcher = new Dispatcher();
345+
this.dispatcher = new Dispatcher();
345346
this.connection = connection;
346347
this.channelName = channel_name;
347348
this.subscribeCb = null;
348349
this.queue = [];
349-
__extends(this, this.dispatcher);
350-
var properies = ['on', 'off', 'emit'];
351-
for (var i in properies) {
350+
__extends(this, this.dispatcher);
351+
var properies = ['on', 'off', 'emit'];
352+
for (var i in properies) {
352353
this[properies[i]] = this.dispatcher[properies[i]];
353-
}
354+
}
354355
}
355356

356357
Channel.prototype.processSubscribe = function () {
@@ -383,7 +384,7 @@ Channel.prototype.trigger = function (event, data) {
383384

384385
////////////////
385386
var Collections = (function () {
386-
var exports = {};
387+
var exports = {};
387388
function extend(target) {
388389
var sources = [];
389390
for (var _i = 1; _i < arguments.length; _i++) {
@@ -490,8 +491,8 @@ var Collections = (function () {
490491
exports.mapObject = mapObject;
491492
function filter(array, test) {
492493
test = test || function (value) {
493-
return !!value;
494-
};
494+
return !!value;
495+
};
495496
var result = [];
496497
for (var i = 0; i < array.length; i++) {
497498
if (test(array[i], i, array, result)) {

0 commit comments

Comments
 (0)