在我的jsp文件中,我有
<script type="text/javascript" src="/resources/scripts/jWebSocket.js"></script>
<script type="text/javascript">
//jws.browserSupportsWebSockets checks if web sockets are available
//either natively, by the FlashBridge or by the ChromeFrame.
if( jws.browserSupportsWebSockets() ) {
jWebSocketClient = new jws.jWebSocketJSONClient();
// Optionally enable GUI controls here
} else {
// Optionally disable GUI controls here
var lMsg = jws.MSG_WS_NOT_SUPPORTED;
alert(lMsg);
}
var lURL = jws.getDefaultSSLServerURL() + "/;timeout=360000";
alert(lURL);
/* var lRes = jWebSocketClient.broadcastText(
"", // broadcast to all clients (not limited to a certain pool)
lMsg // broadcast this message
);
alert(lRes.code);
*/
function broadcast() {
var lMsg = "This is test message";
var lTarget = "*";
if( lMsg.length > 0 ) {
//log( USR, OUT, lMsg );
var lRes;
if( !lTarget || lTarget == "*") {
alert(lMsg);
lRes = jWebSocketClient.broadcastText(
"", // broadcast to all clients (not limited to a certain pool)
lMsg // broadcast this message
);
} else {
lRes = jWebSocketClient.sendText(
lTarget, // broadcast to all clients (not limited to a certain pool)
lMsg // broadcast this message
);
}
// log error only, on success don't confuse the user
if( lRes.code != 0 ) {
alert(lRes.msg);
//log( SYS, OUT, "broadcast: " + lRes.msg );
}
// eMessage.value = "";
}
//doFocus( eMessage );
}
</script>
它不会转到 if(jws.browserSupportsWebSockets()) 的 else 部分。这意味着浏览器支持 websockets。
最后它转到 if( lRes.code != 0 ) 并警告“未连接”
我是不是错过了什么。请帮忙
在我的终端窗口中,我收到了这条消息
TCPEngine: SSL engine 'tcp0' started' at port 9797 with default timeout infinite.
2012-08-15 09:52:45,979 DEBUG - JWebSocketFactory: Starting servers...
2012-08-15 09:52:45,980 INFO - TokenServer: Token server 'ts0' started.
2012-08-15 09:52:45,980 INFO - JWebSocketFactory: jWebSocket server startup complete
这意味着服务器正在运行。
当我从下面的代码中提醒 lURL
var lURL = jws.getDefaultSSLServerURL() + "/;timeout=360000"; in my jsp file.
它打印
wss://localhost:9797/jWebSocket/jWebSocket/;timeout=360000