Cloudbees 现在支持 websockets:http ://wiki.cloudbees.com/bin/view/RUN/WebSockets
我尝试使用 tomcat7 clickStack 在 cloudbees 上实现一个非常简单的测试
您可以在此处看到尝试打开此 websocket 的网页:http ://wstest.ws.cloudbe.es/
这在我的机器上工作,但不在 RUN@cloud
我错过了什么吗?tomcat7 clickStack 不支持 websockets?
提前致谢。
我的小服务程序:
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
import org.apache.catalina.websocket.WsOutbound;
@WebServlet(urlPatterns = "/testWebsocket")
public class TestWebsocket extends WebSocketServlet {
private static final long serialVersionUID = 1L;
@Override
protected StreamInbound createWebSocketInbound(String string, HttpServletRequest hsr) {
return new MessageInbound() {
@Override
protected void onOpen(WsOutbound outbound) {
super.onOpen(outbound);
}
@Override
protected void onClose(int status) {
super.onClose(status);
}
@Override
protected void onBinaryMessage(ByteBuffer bb) throws IOException {
}
@Override
protected void onTextMessage(CharBuffer cb) throws IOException {
System.out.println(cb.toString());
WsOutbound outbound = getWsOutbound();
outbound.writeTextMessage(CharBuffer.wrap((cb.toString()).toCharArray()));
}
};
}
}