jfinal websocket 总是返回200错误

WebSocket connection to 'ws://192.168.10.129:8082/websocket' failed: Error during WebSocket handshake: Unexpected response code: 200

WebSocketHandler Handler {

    ;
    Pattern ;

    WebSocketHandler(String wsUrlPrefix, devMode) {
        .= devMode;
        = Pattern.(wsUrlPrefix);
    }

    handle(String target, HttpServletRequest request, HttpServletResponse response, [] isHandled) {
        (.matcher(target).find()) {
            ;
        }
        .handle(target, request, response, isHandled);
    }

}
;
;
;
;
javax.websocket.Session;
;
java.io.IOException;


()
WebSocketCtrl {
    onOpen(Session session) {
        System..println(+ session.getId());
    }

    onClose(Session session) {
        System..println(+ session.getId());
    }

    onError(Session session, Throwable error) {
        System..println(+ session.getId());
        error.printStackTrace();
    }

    onMessage(String requestJson, Session session) {
        {
            session.getBasicRemote().sendText(requestJson);
        } (IOException e) {
            e.printStackTrace();
        }
    }
}
new WebSocketHandler("^/websocket");

var ws = new WebSocket("ws://192.168.10.129:8082/websocket");

好像不进入 

@ServerEndpoint("/websocket")

注解注册的类里面

评论区

热门反馈

扫码入社