我正在尝试使用 Jetty、Dojo 和 maven 设置 Bayeux 服务器和客户端。
我的问题是道场似乎永远都没有准备好。require 中的回调永远不会被调用。
这是 HTML 页面的代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script data-dojo-config="parseOnLoad:true" src="dojo/dojo.js.uncompressed.js"></script>
<script type="text/javascript">
function initFormListener( onNewForm ) {
require(["dojox/cometd", "dojo/io/script", "dojox/cometd/callbackPollTransport", "dojo/domReady!" ],
function ( cometd, io, callback ) {
console.log(" entered CometD function ");
// Function that manages the connection status with the Bayeux server
var _connected = false;
var _metaConnect = function ( message ) {
if ( cometd.isDisconnected() ) {
_connected = false;
console.log( "disconnected from server " + message );
return;
}
var wasConnected = _connected;
_connected = message.successful === true;
if ( !wasConnected && _connected ) {
console.log( "connected to server " );
}
else if ( wasConnected && !_connected ) {
console.log( "connection broken from server " + message );
}
}
// Function invoked when first contacting the server and
// when the server has lost the state of this client
var _metaHandshake = function ( handshake ) {
if ( handshake.successful === true ) {
cometd.batch( function () {
cometd.subscribe( '/newFormData', function ( message ) {
console.log( "new data for form " + message.formId + " in formData " + message.formDataId );
} );
} );
}
}
// Disconnect when the page unloads
dojo.addOnUnload( function () {
cometd.disconnect( true );
} );
var cometURL = location.protocol + "//" + location.host + "/VisionWeb/cometd";
cometd.configure( {
url:cometURL,
logLevel:'debug'
} );
cometd.addListener( '/meta/handshake', _metaHandshake );
cometd.addListener( '/meta/connect', _metaConnect );
cometd.handshake();
} );
}
initFormListener( function() {console.log("cometd success")});
</script>
</head>
<body>
just some content
</body>
</html>
它不像dojo不能在服务器上工作。确实如此。我的应用程序是用 dojo 1.7.2 编写的
是否存在我不知道的已知问题或我做错了什么?
感谢您提供有关如何找出从未调用回调的原因的任何提示。