现在tomcat7.0.5x支持websocket的哪个协议版本

 我来答
匿名用户
2016-04-17
展开全部
websocketFactory.java
package com.strumsoft.websocket.phonegap;

import java.net.URI;
import java.util.Random;

import android.webkit.WebView;

/**
* The <tt>WebSocketFactory</tt> is like a helper class to instantiate new
* WebSocket instaces especially from Javascript side. It expects a valid
* "ws://" URI.
*
* @author Animesh Kumar
*/
public class WebSocketFactory {

/** The app view. */
WebView appView;

/**
* Instantiates a new web socket factory.
*
* @param appView
* the app view
*/
public WebSocketFactory(WebView appView) {
this.appView = appView;
}

public WebSocket getInstance(String url) {
// use Draft75 by default
return getInstance(url, WebSocket.Draft.DRAFT75);
}

public WebSocket getInstance(String url, WebSocket.Draft draft) {
WebSocket socket = null;
Thread th = null;
try {
socket = new WebSocket(appView, new URI(url), draft, getRandonUniqueId());
th = socket.connect();
return socket;
} catch (Exception e) {
//Log.v("websocket", e.toString());
if(th != null) {
th.interrupt();
}
}
return null;
}

/**
* Generates random unique ids for WebSocket instances
*
* @return String
*/
private String getRandonUniqueId() {
return "WEBSOCKET." + new Random().nextInt(100);
}

}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式