tomcat的websocket客户端怎么写
不是网页版,就是普通的java类里怎么写,向服务器发送消息
var ws = null;
function startServer() {
var url = "ws://127.0.0.1:8080/Demos/echo.ws";
if ('WebSocket' in window) { ws = new WebSocket(url); }
else if ('MozWebSocket' in window) {ws = new MozWebSocket(url);}
else { return; }
function sendMyMessage() {
if (ws != null && textMessage.value != '') {
ws.send( '111111111!@#$%222222222' );
} }//原本JS客户端部分代码如下简化,不知道在JAVA类里该怎么写