class SmWebSocketHandleImpl extends WebSocketDefaultHandler {
    static final Logger log = LoggerFactory.getLogger(SmWebSocketHandleImpl.class);
    static final AttachKey<WebSocketImpl> SESSION_KEY = AttachKey.valueOf("SESSION");

    private final WebSocketRouter webSocketRouter = WebSocketRouter.getInstance();

    @Override
    public void onHandShake(WebSocketRequest request, WebSocketResponse response) {
        WebSocketRequestImpl request1 = (WebSocketRequestImpl) request;

        WebSocketImpl webSocket = new WebSocketImpl(request1);
        request1.getHeaderNames().forEach(name -> {
            webSocket.param(name, request1.getHeader(name));
        });

        if (request1.getAttachment() == null) {
            request1.setAttachment(new Attachment());
        }
        request1.getAttachment().put(SESSION_KEY, webSocket);

        webSocketRouter.getListener().onOpen(webSocket);
    }

    @Override
    public void onClose(Request request) {
        WebSocketRequest request2 = request.newWebsocketRequest();
        onCloseDo(request2);
    }

    @Override
    public void onClose(WebSocketRequest request, WebSocketResponse response, CloseReason closeReason)  {
        onCloseDo(request);
    }

    private void onCloseDo(WebSocketRequest request) {
        WebSocketRequestImpl request1 = (WebSocketRequestImpl) request;

        try {
            WebSocketImpl webSocket = request1.getAttachment().get(SESSION_KEY);
            if (webSocket.isClosed()) {
                return;
            } else {
                webSocket.close();
            }

            webSocketRouter.getListener().onClose(webSocket);
        } finally {
            request1.getAttachment().remove(SESSION_KEY);
        }
    }

    @Override
    public void handlePing(WebSocketRequest request, WebSocketResponse response) {
        super.handlePing(request, response);

        WebSocketRequestImpl request1 = (WebSocketRequestImpl) request;
        WebSocketImpl webSocket = request1.getAttachment().get(SESSION_KEY);
        if (webSocket != null) {
            webSocket.onReceive();
        }
    }

    @Override
    public void handlePong(WebSocketRequest request, WebSocketResponse response) {
        super.handlePong(request, response);

        WebSocketRequestImpl request1 = (WebSocketRequestImpl) request;
        WebSocketImpl webSocket = request1.getAttachment().get(SESSION_KEY);
        if (webSocket != null) {
            webSocket.onReceive();
        }
    }

    @Override
    public void handleTextMessage(WebSocketRequest request, WebSocketResponse response, String data) {
        try {
            WebSocketRequestImpl request1 = (WebSocketRequestImpl) request;
            WebSocketImpl webSocket = request1.getAttachment().get(SESSION_KEY);
            webSocket.onReceive();

            webSocketRouter.getListener().onMessage(webSocket, data);
        } catch (Throwable e) {
            log.warn(e.getMessage(), e);
        }
    }

    @Override
    public void handleBinaryMessage(WebSocketRequest request, WebSocketResponse response, byte[] data) {
        try {
            WebSocketRequestImpl request1 = (WebSocketRequestImpl) request;
            WebSocketImpl webSocket = request1.getAttachment().get(SESSION_KEY);
            webSocket.onReceive();

            webSocketRouter.getListener().onMessage(webSocket, ByteBuffer.wrap(data));
        } catch (Throwable e) {
            log.warn(e.getMessage(), e);
        }
    }

    @Override
    public void onError(WebSocketRequest request, Throwable error) {<FILL_FUNCTION_BODY>}
}

        try {
            WebSocketRequestImpl request1 = (WebSocketRequestImpl) request;
            WebSocket webSocket = request1.getAttachment().get(SESSION_KEY);
            webSocketRouter.getListener().onError(webSocket, error);
        } catch (Throwable e) {
            log.warn(e.getMessage(), e);
        }
    
<methods>public void <init>() ,public final void handle(org.smartboot.http.server.WebSocketRequest, org.smartboot.http.server.WebSocketResponse) throws java.io.IOException,public void handleBinaryMessage(org.smartboot.http.server.WebSocketRequest, org.smartboot.http.server.WebSocketResponse, byte[]) ,public void handlePing(org.smartboot.http.server.WebSocketRequest, org.smartboot.http.server.WebSocketResponse) ,public void handlePong(org.smartboot.http.server.WebSocketRequest, org.smartboot.http.server.WebSocketResponse) ,public void handleTextMessage(org.smartboot.http.server.WebSocketRequest, org.smartboot.http.server.WebSocketResponse, java.lang.String) ,public void onClose(org.smartboot.http.server.WebSocketRequest, org.smartboot.http.server.WebSocketResponse, org.smartboot.http.common.codec.websocket.CloseReason) ,public void onError(org.smartboot.http.server.WebSocketRequest, java.lang.Throwable) ,public void onHandShake(org.smartboot.http.server.WebSocketRequest, org.smartboot.http.server.WebSocketResponse) ,public void whenHeaderComplete(org.smartboot.http.server.impl.WebSocketRequestImpl, org.smartboot.http.server.impl.WebSocketResponseImpl) <variables>private static final org.smartboot.http.common.logging.Logger LOGGER