<commit_before>package controllers;

import java.util.concurrent.CompletableFuture;

import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.BoundRequestBuilder;
import org.asynchttpclient.ListenableFuture;
import org.asynchttpclient.ws.WebSocket;
import org.asynchttpclient.ws.WebSocketListener;
import org.asynchttpclient.ws.WebSocketUpgradeHandler;

public class WebSocketClient {
	
	private AsyncHttpClient client;
	
	public WebSocketClient(AsyncHttpClient c) {
		this.client = c;
	}
	
	public CompletableFuture<WebSocket> call(String url, WebSocketListener listener) {
		BoundRequestBuilder requestBuilder = client.prepareGet(url);
		
		final WebSocketUpgradeHandler handler = new WebSocketUpgradeHandler.Builder().addWebSocketListener(listener).build();
		final ListenableFuture<WebSocket> future = requestBuilder.execute(handler);
		final CompletableFuture<WebSocket> completableFuture = future.toCompletableFuture();
		return completableFuture;
	}

}<commit_msg>added logginlistener static class<commit_after>package controllers;

import java.util.concurrent.CompletableFuture;

import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.BoundRequestBuilder;
import org.asynchttpclient.ListenableFuture;
import org.asynchttpclient.ws.WebSocket;
import org.asynchttpclient.ws.WebSocketListener;
import org.asynchttpclient.ws.WebSocketUpgradeHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WebSocketClient {
	
	private AsyncHttpClient client;
	
	public WebSocketClient(AsyncHttpClient c) {
		this.client = c;
	}
	
	public CompletableFuture<WebSocket> call(String url, WebSocketListener listener) {
		BoundRequestBuilder requestBuilder = client.prepareGet(url);
		
		final WebSocketUpgradeHandler handler = new WebSocketUpgradeHandler.Builder().addWebSocketListener(listener).build();
		final ListenableFuture<WebSocket> future = requestBuilder.execute(handler);
		final CompletableFuture<WebSocket> completableFuture = future.toCompletableFuture();
		return completableFuture;
	}
	
	static class LoggingListener implements WebSocketListener {
		
		private Logger logger = LoggerFactory.getLogger(LoggingListener.class);
		
		private Throwable throwableFound = null;
		
		public Throwable getThrowable() {
			return throwableFound;
		}

		@Override
		public void onOpen(WebSocket websocket) {
			logger.info("On open: ");
			websocket.sendMessage("hello");
		}

		@Override
		public void onClose(WebSocket websocket) {
			logger.info("onClose: ");
		}

		@Override
		public void onError(Throwable t) {
			logger.error("onError: ", t);
			throwableFound = t;
		}
		
	}

}
{'fraction_non_alphanumeric': 0.08352315869400152, 'fraction_numerical': 0.0007593014426727411, 'mean_word_length': 6.121621621621622, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3388347', 'n_tokens_mistral': 831, 'n_tokens_neox': 755, 'n_words': 150}