diff options
author | HampusM <hampus@hampusmat.com> | 2022-05-14 12:57:01 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-05-14 12:57:01 +0200 |
commit | 39e2964b0315faeac0c9f8431334ba10093b9490 (patch) | |
tree | 9cae9425845b32eac5c0b5c1e93601f09e718a21 /minion/src/gymnasiearbete.cpp | |
parent | cd00813c0740930d389f935f0c2d7d8a11eef02d (diff) |
refactor(minion): create network connection class
Diffstat (limited to 'minion/src/gymnasiearbete.cpp')
-rw-r--r-- | minion/src/gymnasiearbete.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/minion/src/gymnasiearbete.cpp b/minion/src/gymnasiearbete.cpp index 092250a..b31cf81 100644 --- a/minion/src/gymnasiearbete.cpp +++ b/minion/src/gymnasiearbete.cpp @@ -74,17 +74,20 @@ void setup() void loop() { - const auto request = wifi_module.read_incoming_request(); + auto request = wifi_module.read_incoming_request(); - if (request.connection_id() == -1) + auto connection = request.connection(); + + if (connection.id() == -1) { return; } - const auto connection_id = request.connection_id(); - Serial.print("Connection ID: "); - Serial.println(static_cast<unsigned int>(connection_id)); + Serial.println(connection.id()); + + Serial.print("Connection closed: "); + Serial.println(connection.is_closed() ? "true" : "false"); Serial.print("Request method: "); Serial.println(http_request_method_strs[static_cast<size_t>(request.method())]); @@ -98,9 +101,12 @@ void loop() Serial.print("\nData: "); Serial.println(request.data()); - wifi_module.send_response(connection_id, 200U, "hello there!"); + wifi_module.send_response(connection, 200U, "hello there!"); + + wifi_module.close_connection(connection); - wifi_module.close_connection(connection_id); + Serial.print("Connection closed: "); + Serial.println(connection.is_closed() ? "true" : "false"); delay(SECOND_IN_MILLIS); } |