Java Websocket: jakrata.websocket interceptor

98 views Asked by At

I want to enrich (or use other way) the ClientEndpointConfig.Configurator of jakarta.websocket.

I'm using tyrus as the implementation and I have something like:

public class WebsocketClientEndpointConfigurator extends ClientEndpointConfig.Configurator {

    private MyCreds credential;

    public WebsocketClientEndpointConfigurator(MyCreds credential) {
        this.credential = credential;
    }

    @Override
    public void beforeRequest(Map<String, List<String>> headers) {
        try {
            credential.intercept(null);
        } catch (IOException e) {
            e.printStackTrace();
        }

        headers.put(AUTHORIZATION, Arrays.asList(credential.getAccessToken()));
    }
}

It's seems that the beforeRequest called only once, I would like that it will be execute before each message sends to the server.

How is it possible?

0

There are 0 answers