服务器触发的事件

时间:2014-04-21 12:55:45

标签: javascript jquery publish-subscribe

我的服务器在client1的某些请求中向client2触发事件。客户端2正确捕获了触发事件。

见下面的代码:

'experimentService.experimentPermissionChangedByOwner subscribe': function(eventName, event){

            if(this.resource.id == event.eventData.resource) {
                if (event.eventData.permissionType == "unshare") {  
                    message = this.resource.name +" has been unshared by the owner: "+event.eventData.ownerUsername+". "+messagePart2;
                    this.openWorkspaceObject({id: event.eventData.dashboardId, namespace: "bjkbb", type: "jhvhhkk" });
                }
                else {
                    message = "Owner: "+event.eventData.ownerUsername+" changed permission of "+ this.resource.name +" to "+ event.eventData.permissionType +". ";
                    if (event.eventData.permissionType == "view") {
                        message += messagePart2;
                    }
                    this.publish("elements.atlas.resource-page-modified", this.resource); 
                }

                this.openDialog({
                    dialogClass: elements.AlertCollaborators,
                    message: message
                });
            }

        this.publish("event.ack", {eventId: event.id});
    }, 

上面的代码将创建一个带有消息的小对话框。现在的问题是刷新浏览器,它再次进入订阅功能。我不知道如何处理这个?无论在调试点之后我都看到它没有用于此方法的发布。那么subcribe如何再次捕获它?

0 个答案:

没有答案