/// <summary> /// This method is run on the server thread. /// Acts as a server, waiting for any request through the HttpListener. /// Expects a request on a file present in the local file's directory. Whenever it receives one, it reads the file and writes its content in the request's OutputStream. /// The request must contain a query parameter named behaviour, with the desired behaviour to be simulated by this server while answering the respective request. /// </summary> private static void ServerThread() { while (true) { HttpListenerContext context = httpListener.GetContext(); int behaviour = int.Parse(context.Request.QueryString["behaviour"]); string file = ServerFilesDirectory + context.Request.Url.LocalPath; if (!File.Exists(file)) { context.Response.StatusCode = 404; context.Response.Close(); continue; } byte[] buffer = new byte[DownloaderConfigs.BUFFER_SIZE]; if (NormalBehaviour.IsThisKind(behaviour)) { new NormalBehaviour().ComputeBehaviour(context, buffer, file); } if (LatencyBehaviour.IsThisKind(behaviour)) { new LatencyBehaviour().ComputeBehaviour(context, buffer, file); } if (TimeoutBehaviour.IsThisKind(behaviour)) { new TimeoutBehaviour().ComputeBehaviour(context, buffer, file); } if (InconsistentBehaviour.IsThisKind(behaviour)) { new InconsistentBehaviour().ComputeBehaviour(context, buffer, file); } context.Response.Close(); } }
private void Awake() { moleSpeed = 5; moleStandbyTime = 2; scoreBonus = 10; MoleBehaviour = new NormalBehaviour(); GetComponent <MeshRenderer>().material.color = Color.green; }