<commit_before>package main

import (
	"flag"
	"github.com/canopener/PongPlusPlus-Server/server/connection"
	"github.com/canopener/serverlog"
	"net"
	"os"
	"strconv"
)

var unRegisteredConnections = make(map[string]*connection.Connection)
var registeredConnections = make(map[string]*connection.Connection)

func main() {
	help := flag.Bool("h", false, "Display this help message")
	consoleLog := flag.Bool("C", false, "Allow logging to the console, default wont log")
	fileLog := flag.String("L", "", "Specify directory for logging logfiles, default wont log")
	logcount := flag.Int("N", -1, "Specify maximum logfiles in directory, default no limit")
	portno := flag.Int("PORT", 3000, "Specify the port on which the server should listen, default 3000")
	flag.Parse()

	if *help {
		flag.PrintDefaults()
		os.Exit(1)
	}

	serverlog.Init(*consoleLog, (*fileLog != ""), *logcount, *fileLog)
	serverlog.Startup("Server listening on localhost:", *portno)
	listener, err := net.Listen("tcp", ":"+strconv.Itoa(*portno))
	if err != nil {
		serverlog.Fatal(err)
	}
	defer listener.Close()

	for {
		socket, err := listener.Accept()
		if err != nil {
			serverlog.Fatal(err)
		}
		conn := connection.NewConnection(socket)
		unRegisteredConnections[conn.Alias] = conn
		conn.StartRoutines()
	}
}<commit_msg>Connection message router and connection management<commit_after>package main

import (
	"flag"
	"github.com/canopener/PongPlusPlus-Server/server/connection"
	"github.com/canopener/PongPlusPlus-Server/server/messages"
	"github.com/canopener/serverlog"
	"net"
	"os"
	"strconv"
)

var unRegisteredConnections = make(map[string]*connection.Connection)
var registeredConnections = make(map[string]*connection.Connection)

func main() {
	help := flag.Bool("h", false, "Display this help message")
	consoleLog := flag.Bool("C", false, "Allow logging to the console, default wont log")
	fileLog := flag.String("L", "", "Specify directory for logging logfiles, default wont log")
	logcount := flag.Int("N", -1, "Specify maximum logfiles in directory, default no limit")
	portno := flag.Int("PORT", 3000, "Specify the port on which the server should listen, default 3000")
	flag.Parse()

	if *help {
		flag.PrintDefaults()
		os.Exit(1)
	}

	serverlog.Init(*consoleLog, (*fileLog != ""), *logcount, *fileLog)
	serverlog.Startup("Server listening on localhost:", *portno)
	listener, err := net.Listen("tcp", ":"+strconv.Itoa(*portno))
	if err != nil {
		serverlog.Fatal(err)
	}
	defer listener.Close()

	for {
		socket, err := listener.Accept()
		if err != nil {
			serverlog.Fatal(err)
		}
		conn := connection.NewConnection(socket)
		unRegisteredConnections[conn.Alias] = conn
		conn.StartRoutines()
	}
}

func routeMessages(conn *connection.Connection) {
	for {
		select {
		case message := <-conn.IncommingMessages:
			mType := uint8(message[0])
			switch mType {
			case messages.TypeRequestAlias:
				// TODO: route message
			case messages.TypeRequestGameList:
				// TODO: route message
			case messages.TypeCreateGame:
				// TODO: route message
			case messages.TypeJoinGame:
				// TODO: route message
			case messages.TypeLeaveGame:
				// TODO: route message
			case messages.TypeMove:
				// TODO: route message
			default:
				serverlog.General("Router for conn:", conn.Alias, "Killed")
				if conn.Registered {
					delete(registeredConnections, conn.Alias)
				} else {
					delete(unRegisteredConnections, conn.Alias)
				}
				return
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.13876013904982618, 'fraction_numerical': 0.006373117033603708, 'mean_word_length': 4.420722135007849, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 3, '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': '7411043', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1111, 'n_words': 276}