com.gitee.rabbitnoteeth.bedrock.http.server.handler.SockJSHandler Maven / Gradle / Ivy
The newest version!
package com.gitee.rabbitnoteeth.bedrock.http.server.handler;
import io.vertx.core.Handler;
import io.vertx.ext.web.handler.sockjs.SockJSSocket;
import java.nio.charset.StandardCharsets;
public class SockJSHandler implements Handler {
private final ISockJSEndPoint endPoint;
public SockJSHandler(ISockJSEndPoint endPoint) {
this.endPoint = endPoint;
}
@Override
public void handle(SockJSSocket socket) {
endPoint.onOpen(socket);
socket.handler(message -> endPoint.onMessage(socket, message.toString(StandardCharsets.UTF_8)));
socket.drainHandler(v -> endPoint.onDrain(socket));
socket.exceptionHandler(e -> endPoint.onException(socket, e));
socket.closeHandler(v -> endPoint.onClose(socket));
socket.endHandler(v -> endPoint.onEnd(socket));
}
}