0
在我的JSP文件中我有jWebsocket未連接錯誤
<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>
它不會去的這個else部分,如果(jws.browserSupportsWebSockets())。這意味着瀏覽器支持websockets。
最後它去,如果(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