<commit_before>var io = require('socket.io')(8080);//websocket server
var drone = require('ar-drone');
var client = drone.createClient();//controllable aspect of drone<commit_msg>Command handling<commit_after>var io = require('socket.io')(8080);//websocket server
var drone = require('ar-drone');
var client = drone.createClient();//controllable aspect of drone



io.on('connection', function (socket) {//when we get a connection, presumably from the Unity client

	console.log("Unity connected");

	socket.on('message', function (data) {
		console.log(data);//command passed from unity
		handleMessage(data);//this runs the code on the drone
	});

});


function handleMessage(message){//process the message passed from the wss to this server, act accordingly

	/*
		Current messages to deal with
		As the entire message must be a string, args will be passed as such
		"command-arg1,arg2,arg3..."

		*	"takeoff"		- takes off
		*	"land"			- lands
		*	"stop"			- stops moving & rotating
		*	"move-[0-1]"	- moves at a speed from 0 to 1
		*	"turncw-[0-1]"	- moves clockwise at a speed from 0 to 1
		*	"turnccw-[0-1]"	- moves counterclockwise at a speed from 0 to 1

	*/

	var parts = message.split("-");
	var command = parts[0].toLowerCase();//first part, the command passed

	switch(command){
		case "takeoff"://for this method and the one below, we should add callbacks so that the oculus knows when it landed
			client.takeoff();
			break;
		case "land":
			client.land();
			break;
		case "stop":
			client.stop();
			break;
		case "move":
			if(parts.length<2)//not enough args...
				break;
			var speed = parseFloat(parts[1]);
			client.move(speed);
		case "turncw":
			if(parts.length<2)
				break;
			var speed = parseFloat(parts[1]);
			client.clockwise(speed);
		case "turnccw":
			if(parts.length<2)
				break;
			var speed = parseFloat(parts[1]);
			client.counterclockwise(speed);


	}

}
{'fraction_non_alphanumeric': 0.13842105263157894, 'fraction_numerical': 0.015789473684210527, 'mean_word_length': 3.6365853658536587, 'pattern_counts': {'":': 6, '<': 6, '<?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': '2723276', 'n_tokens_mistral': 708, 'n_tokens_neox': 607, 'n_words': 193}