/// <summary> /// /// </summary> /// <param name="e"></param> protected virtual void OnRequestReceivedFunction(OnRequestReceivedArgs e) { OnRequestReceived(this, e); }
void server_OnRequestReceived(object sender, OnRequestReceivedArgs e) { if (DataSource == null) { return; } NDLogger.Log("HTTP Request received: " + new string (Encoding.UTF8.GetChars(e.Request)) + " File name: " + e.FileName, LogLevel.Verbose); if (e.FileName == "sensor_data.csv") { try { RespondWithSensorDataFile(); } catch (Exception ex) { HttpService.SendInternalServerError(ex.Message); } } else if (e.FileName == "") { try { RespondWithLocalFile(@"\SD\\index.html"); } catch (Exception ex) { HttpService.SendInternalServerError(ex.Message); } } else if (e.IsInMemoryCard) { try { RespondWithLocalFile(e.FileName); } catch (Exception ex) { HttpService.SendInternalServerError(ex.Message); } } else if (e.FileName.IndexOf("setMqttConfiguration.html") > -1) { string fileName, username, password, host; string[] split = e.FileName.Split(new char[] { '?' }); fileName = split[0]; string[] parameters = split[1].Split(new char[] { '&' }); username = parameters[0].Split(new char[] { '=' })[1]; password = parameters[1].Split(new char[] { '=' })[1]; host = parameters[2].Split(new char[] { '=' })[1]; onMqttConfigurationReceived(host, username, password); HttpService.SendOK(); } else if (e.FileName.IndexOf("mqtt_configuration.csv") > -1) { try { RespondWithMqttConfigurationFile(); } catch (Exception ex) { HttpService.SendInternalServerError(ex.Message); } } }