在我的grails 2.3.7应用程序中,我使用了atmosphere meteor 0.8.3。
在我的主页加载时,我订阅客户端。默认情况下,我运行长轮询;它工作得很好。在页面刷新时,我取消订阅客户端。
但是,如果我刷新页面,那么一些JS和CSS将无法加载。它发生在10次刷新中的5次。
我做错什么了吗?(因为我在document.ready()上订阅)。或者我还需要做别的什么吗?
任何帮助都是非常感谢的。
更新:
订阅的gsp内部代码:
$('body').bind('beforeunload',function(){
Jabber.unsubscribe();
});
$(document).ready(function () {
if (typeof atmosphere == 'undefined') {
Jabber.socket = $.atmosphere;
} else {
Jabber.socket = atmosphere;
}
var atmosphereRequest = {
type: 'public',
url: 'atmosphere/public',
trackMessageLength: false
};
//setTimeout(function(){
Jabber.subscribe(atmosphereRequest);
//}, 10000);
});和Jabber变量
var Jabber = {
socket: null,
publicSubscription: null,
transport: null,
subscribe: function (options) {
var defaults = {
type: '',
contentType: "application/json",
shared: false,
//transport: 'websocket',
transport: 'long-polling',
fallbackTransport: 'long-polling',
trackMessageLength: true
},
atmosphereRequest = $.extend({}, defaults, options);
console.log(atmosphereRequest);
atmosphereRequest.onOpen = function (response) {
console.log('atmosphereOpen transport: ' + response.transport);
};
atmosphereRequest.onReconnect = function (request, response) {
console.log("atmosphereReconnect");
};
atmosphereRequest.onMessage = function (response) {
console.log("on message");
Jabber.onMessage(response);
};
atmosphereRequest.onError = function (response) {
console.log('atmosphereError: ' + response);
};
atmosphereRequest.onTransportFailure = function (errorMsg, request) {
console.log('atmosphereTransportFailure: ' + errorMsg);
};
atmosphereRequest.onClose = function (response) {
console.log('atmosphereClose: ' + response);
};
switch (options.type) {
case 'public':
Jabber.publicSubscription = Jabber.socket.subscribe(atmosphereRequest);
break;
default:
return false;
}
//Jabber.publicSubscription = Jabber.socket.subscribe(atmosphereRequest);
},
unsubscribe: function () {
if (Jabber.socket)
Jabber.socket.unsubscribe();
},
onMessage:function(response){....}
}发布于 2014-09-11 00:38:31
我是插件的作者。请更新到版本1.0.1。如果您在更新插件后仍然有问题,请使用create a new issue。到时候我们可以解决这个问题。然而,我确实有一个问题。当你说JS加载失败时,你是指atmosphere还是你自己的?没有与CSS相关的插件。
https://stackoverflow.com/questions/25767526
复制相似问题