<commit_before>package websockets;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.websocket.server.WebSocketHandler;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;

import processing.core.PApplet;

/**
 *
 * @author <NAME>
 * @author <NAME> (changes)
 *
 */
public class WebsocketServer {
	private WebsocketServerController serverController;

	private static int MAX_MSG_SIZE = 65536;

	/**
	 *
	 * The websocket server object that is initiated directly in the Processing sketch
	 *
	 * @param parent Processing's PApplet object
	 * @param port The port number you want the websocket server to initiate its connection on
	 * @param uri The uri you want your server to respond to. Ex. /john (if the port is set to ex. 8025, then the full URI would be ws://localhost:8025/john).
	 */
	public WebsocketServer(PApplet parent, int port, String uri){
		this(parent, parent, port, uri);
	}

	/**
	 *
	 * @param parent Processing's PApplet object
	 * @param listenerObject The object implementing .webSocketServerEvent()
	 * @param port The port number you want the websocket server to initiate its connection on
	 * @param uri The uri you want your server to respond to. Ex. /john (if the port is set to ex. 8025, then the full URI would be ws://localhost:8025/john).
	 */
	public WebsocketServer(PApplet parent, Object listenerObject, int port,
						   String uri) {

		parent.registerMethod("dispose", this);

		Server server = new Server(port);
		serverController = new WebsocketServerController(listenerObject);

		WebSocketHandler wsHandler = new WebSocketHandler() {

			@Override
			public void configure(WebSocketServletFactory factory){
				factory.getPolicy().setMaxTextMessageSize(MAX_MSG_SIZE);
				factory.getPolicy().setMaxBinaryMessageSize(MAX_MSG_SIZE);
				factory.setCreator(new WebsocketServerCreator(serverController));
			}
		};

		ContextHandler contextHandler = new ContextHandler(uri);
		contextHandler.setAllowNullPathInfo(true); // disable redirect from /ws to /ws/
		contextHandler.setHandler(wsHandler);

		server.setHandler(contextHandler);<commit_msg>Disable INFO log messages that look like an error in Processing<commit_after>package websockets;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.websocket.server.WebSocketHandler;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;

import processing.core.PApplet;

/**
 *
 * @author <NAME>
 * @author <NAME> (changes)
 *
 */
public class WebsocketServer {
	private WebsocketServerController serverController;

	private static int MAX_MSG_SIZE = 65536;

	/**
	 *
	 * The websocket server object that is initiated directly in the Processing sketch
	 *
	 * @param parent Processing's PApplet object
	 * @param port The port number you want the websocket server to initiate its connection on
	 * @param uri The uri you want your server to respond to. Ex. /john (if the port is set to ex. 8025, then the full URI would be ws://localhost:8025/john).
	 */
	public WebsocketServer(PApplet parent, int port, String uri){
		this(parent, parent, port, uri);
	}

	/**
	 *
	 * @param parent Processing's PApplet object
	 * @param listenerObject The object implementing .webSocketServerEvent()
	 * @param port The port number you want the websocket server to initiate its connection on
	 * @param uri The uri you want your server to respond to. Ex. /john (if the port is set to ex. 8025, then the full URI would be ws://localhost:8025/john).
	 */
	public WebsocketServer(PApplet parent, Object listenerObject, int port,
						   String uri) {

		parent.registerMethod("dispose", this);

		System.setProperty("org.eclipse.jetty.util.log.class",
				"org.eclipse.jetty.util.log.StdErrLog");
		System.setProperty("org.eclipse.jetty.LEVEL", "OFF");

		Server server = new Server(port);
		serverController = new WebsocketServerController(listenerObject);

		WebSocketHandler wsHandler = new WebSocketHandler() {

			@Override
			public void configure(WebSocketServletFactory factory){
				factory.getPolicy().setMaxTextMessageSize(MAX_MSG_SIZE);
				factory.getPolicy().setMaxBinaryMessageSize(MAX_MSG_SIZE);
				factory.setCreator(new WebsocketServerCreator(serverController));
			}
		};

		ContextHandler contextHandler = new ContextHandler(uri);
		contextHandler.setAllowNullPathInfo(true); // disable redirect from /ws to /ws/
		contextHandler.setHandler(wsHandler);

		server.setHandler(contextHandler);
{'fraction_non_alphanumeric': 0.09250714128762909, 'fraction_numerical': 0.00922874093605801, 'mean_word_length': 4.599015990159901, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5268654', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1255, 'n_words': 407}