<commit_before>#!/usr/bin/env python3

import socket
import atexit
import _thread
from message import Message
from thruster_controller import ThrusterController

# It is possible for a host to have multiple IP addresses. Using 0.0.0.0
# will listen on all network interfaces on this host
HOST = "0.0.0.0"
PORT = 9999


def on_new_client(clientsocket, addr):
    '''
    This function is responsible for communicating with an active socket
    connection. All input is passed directly to the thruster controller making
    this very lightweight. If we get an empty message from the client, this
    indicates that the conection needs to be shutdown

    NOTE: The functionality in here is bare bones. It would be wise to
    introduce a handshake upon initial connection with the client. This
    handshake should confirm that the version of this server and the version of
    the client are compatible. This implies that our responses need to grow in
    complexity.
    '''
    controller = ThrusterController()

    while True:
        msg = clientsocket.recv(1024)

        if msg == b'':
            print("disconnecting client")
            break
        else:
            m = Message(msg)
            if m.type == 0:
                controller.update_axis(m.input_index, m.input_value)
            elif m.type == 1:
                controller.update_button(m.input_index, m.input_value)

        # this is a simple confirmation to the client that we have received its
        # message and have processed it correctly. Ideally, this would be more
        # formalized allowing for error responses and such.
        clientsocket.send("OK".encode())

    clientsocket.close()


def close_socket():<commit_msg>Fix property name reference<commit_after>#!/usr/bin/env python3

import socket
import atexit
import _thread
from message import Message
from thruster_controller import ThrusterController

# It is possible for a host to have multiple IP addresses. Using 0.0.0.0
# will listen on all network interfaces on this host
HOST = "0.0.0.0"
PORT = 9999


def on_new_client(clientsocket, addr):
    '''
    This function is responsible for communicating with an active socket
    connection. All input is passed directly to the thruster controller making
    this very lightweight. If we get an empty message from the client, this
    indicates that the conection needs to be shutdown

    NOTE: The functionality in here is bare bones. It would be wise to
    introduce a handshake upon initial connection with the client. This
    handshake should confirm that the version of this server and the version of
    the client are compatible. This implies that our responses need to grow in
    complexity.
    '''
    controller = ThrusterController()

    while True:
        msg = clientsocket.recv(1024)

        if msg == b'':
            print("disconnecting client")
            break
        else:
            m = Message(msg)
            if m.input_type == 0:
                controller.update_axis(m.input_index, m.input_value)
            elif m.input_type == 1:
                controller.update_button(m.input_index, m.input_value)

        # this is a simple confirmation to the client that we have received its
        # message and have processed it correctly. Ideally, this would be more
        # formalized allowing for error responses and such.
        clientsocket.send("OK".encode())

    clientsocket.close()


def close_socket():
{'fraction_non_alphanumeric': 0.05793742757821553, 'fraction_numerical': 0.01100811123986095, 'mean_word_length': 2.769650655021834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '2635651', 'n_tokens_mistral': 904, 'n_tokens_neox': 859, 'n_words': 396}