<commit_before>package de.c3seidenstrasse.networkcontroller.webservice;

import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.websocket.CloseReason;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;

import de.c3seidenstrasse.networkcontroller.network.NetworkComponent;
import de.c3seidenstrasse.networkcontroller.network.states.NetworkState;

@ServerEndpoint("/websocket")
public class WebServer extends GuiUpdater {
	Set<Session> sessions = new HashSet<>();

	@OnOpen
	synchronized public void onOpen(final Session session) {
		System.out.println("WebSocket opened: " + session.getId());
		this.sessions.add(session);
	}

	@OnMessage
	public void onMessage(final String txt, final Session session) throws IOException {
		System.out.println("Message received: " + txt);
		session.getBasicRemote().sendText(txt.toUpperCase());
	}

	@OnClose
	synchronized public void onClose(final CloseReason reason, final Session session) {
		System.out.println("Closing a WebSocket due to " + reason.getReasonPhrase());
		this.sessions.remove(session);
	}

	// --------------------------------------------------------------------------------

	synchronized private void sendToAll(final String message) {
		final Iterator<Session> i = this.sessions.iterator();
		while (i.hasNext()) {
			i.next().getAsyncRemote().sendText(message);
		}
	}

	@Override
	public void updateNode(final NetworkComponent nc) {
		// TODO Auto-generated method stub

	}

	@Override
	public void updateState(final NetworkState ns) {
		// TODO Auto-generated method stub

	}
}<commit_msg>filled update methods<commit_after>package de.c3seidenstrasse.networkcontroller.webservice;

import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.websocket.CloseReason;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;

import com.google.gson.Gson;

import de.c3seidenstrasse.networkcontroller.network.NetworkComponent;
import de.c3seidenstrasse.networkcontroller.network.states.NetworkState;

@ServerEndpoint("/websocket")
public class WebServer extends GuiUpdater {
	Set<Session> sessions = new HashSet<>();
	Gson gson = new Gson();

	@OnOpen
	synchronized public void onOpen(final Session session) {
		System.out.println("WebSocket opened: " + session.getId());
		this.sessions.add(session);
	}

	@OnMessage
	public void onMessage(final String txt, final Session session) throws IOException {
		System.out.println("Message received: " + txt);
		session.getBasicRemote().sendText(txt.toUpperCase());
	}

	@OnClose
	synchronized public void onClose(final CloseReason reason, final Session session) {
		System.out.println("Closing a WebSocket due to " + reason.getReasonPhrase());
		this.sessions.remove(session);
	}

	// --------------------------------------------------------------------------------

	synchronized private void sendToAll(final String message) {
		final Iterator<Session> i = this.sessions.iterator();
		while (i.hasNext()) {
			i.next().getAsyncRemote().sendText(message);
		}
	}

	@Override
	public void updateNode(final NetworkComponent nc) {
		final String message = this.gson.toJson(new NodeChanged(nc));
		this.sendToAll(message);
	}

	@Override
	public void updateState(final NetworkState ns) {
		final String message = this.gson.toJson(new StateChanged(ns));
		this.sendToAll(message);
	}
}
{'fraction_non_alphanumeric': 0.15046677649643053, 'fraction_numerical': 0.0016474464579901153, 'mean_word_length': 4.2117310443490705, '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': '981798', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1061, 'n_words': 236}