All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.contek.invoker.deribit.api.websocket.WebSocketRequestIdGenerator Maven / Gradle / Ivy

package io.contek.invoker.deribit.api.websocket;

import io.contek.invoker.deribit.api.websocket.common.WebSocketResponse;

import javax.annotation.concurrent.ThreadSafe;
import java.util.concurrent.atomic.AtomicInteger;

@ThreadSafe
public final class WebSocketRequestIdGenerator {

  private final WebSocketMessageParser parser;

  private final AtomicInteger count = new AtomicInteger(0);

  public WebSocketRequestIdGenerator(WebSocketMessageParser parser) {
    this.parser = parser;
  }

  public int getNextRequestId(Class> type) {
    int id = count.incrementAndGet();
    parser.register(id, type);
    return id;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy