extends Node var server: TCPServer signal started signal received(auth) var clients: Array[StreamPeerTCP] = [] var listening = false func start(): var port = get_parent().auth.PORT print(port) server = TCPServer.new() server.listen(port) func _process(delta): if !server: return if(!server.is_listening()): return; if not listening: print("SERVER STARTED") started.emit() listening = true if(server.is_connection_available()): _handle_connect(); for client in clients: _process_request(client); func _handle_connect(): var client := server.take_connection() clients.push_back(client) print("CONNECT") func _process_request(client: StreamPeerTCP): match client.get_status(): StreamPeerTCP.STATUS_CONNECTED: client.poll() if client.get_available_bytes() > 0: var string = client.get_utf8_string(client.get_available_bytes()) var split = string.split("\n") var first = split[0] var regex = RegEx.new() regex.compile("code=(.*)&") var result = regex.search(first) if result: var auth = result.get_string(1) _send_response(client, "200 OK", "