@OnMessage
  public WebsocketMessageWrapper doLogin(WebsocketMessageWrapper<Customer> message) {
    Customer customer =
        loginBean.findCustomer(message.getData().getEmail(), message.getData().getPassword());
    if (customer == null) {
      throw WebSocketServerLogger.LOG.customerNotFoundException(
          message.getData().getEmail(), message.getSequenceId());
    }

    ApiToken apiToken = loginBean.findValidToken(customer);
    if (apiToken == null) {
      apiToken = loginBean.createToken(customer);
    } else {
      apiToken = loginBean.refreshToken(apiToken);
    }

    // loginBean.refreshToken(customer.getEmail(), customer.getPassword(), message.getSequenceId());

    WebsocketMessageWrapper<ApiToken> token = new WebsocketMessageWrapper<>();
    token.setType(WebsocketMessageType.CUSTOMER_API_TOKEN);
    token.setSequenceId(message.getSequenceId());
    token.setData(apiToken);

    return token;
  }
  @OnError
  public void errorHandle(Session session, Throwable error) {
    if (session != null && session.isOpen()) {
      WebsocketMessageWrapper<Error> response = new WebsocketMessageWrapper<>();
      response.setType(WebsocketMessageType.CUSTOMER_ERROR);
      response.setData(new Error());
      if (error instanceof CustomerNotFoundException) {
        response.setSequenceId(((CustomerNotFoundException) error).getSequenceId());
        response.getData().setCode("customer.notFound");
        response.getData().setDescription("Customer not found");
      } else {
        WebSocketServerLogger.LOG.handleWebsocketServerError(error);

        response.setSequenceId(UUID.randomUUID().toString());
        response.getData().setCode(error.getClass().getName());
        response.getData().setDescription("Handled exception");
      }

      session.getAsyncRemote().sendObject(response);
    }
  }