abouttreesummaryrefslogcommitdiff
path: root/src/matrix_http_mongoose.c
diff options
context:
space:
mode:
authorPatrick2023-07-03 13:39:12 +0200
committerPatrick2023-07-03 13:39:12 +0200
commita6eff84624ab1f3786d02aa2ec740b9a88090d94 (patch)
tree7603296a72dca1d289be923fbae47d36109c6bdb /src/matrix_http_mongoose.c
parentfb5f3a8652d1cd3e4d8207f8718359f90636b5b3 (diff)
downloadmatrix_esp_thesis-a6eff84624ab1f3786d02aa2ec740b9a88090d94.tar.gz
matrix_esp_thesis-a6eff84624ab1f3786d02aa2ec740b9a88090d94.zip
upload device/onetime keys, fix recurring http accesses
Diffstat (limited to 'src/matrix_http_mongoose.c')
-rw-r--r--src/matrix_http_mongoose.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/matrix_http_mongoose.c b/src/matrix_http_mongoose.c
index 2e500d6..17edbc8 100644
--- a/src/matrix_http_mongoose.c
+++ b/src/matrix_http_mongoose.c
@@ -58,6 +58,11 @@ MatrixHttpCallback(
printf("received[%d]:\n%.*s\n", conn->dataLen, conn->dataLen, conn->data);
}
+ if (ev == MG_EV_CLOSE)
+ {
+ conn->connection = NULL;
+ conn->connected = false;
+ }
}
bool
@@ -71,6 +76,16 @@ MatrixHttpInit(
mg_mgr_init(&conn->mgr);
+ return MatrixHttpConnect(client);
+}
+
+bool
+MatrixHttpConnect(
+ MatrixClient * client)
+{
+ MatrixHttpConnection * conn =
+ (MatrixHttpConnection *)client->httpUserData;
+
struct mg_connection * c =
mg_http_connect(&conn->mgr, client->server, MatrixHttpCallback, client);
@@ -101,6 +116,8 @@ MatrixHttpGet(
bool authenticated)
{
MatrixHttpConnection * conn = (MatrixHttpConnection *)client->httpUserData;
+ if (! conn->connected)
+ MatrixHttpConnect(client);
conn->dataReceived = false;
@@ -142,6 +159,8 @@ MatrixHttpPost(
bool authenticated)
{
MatrixHttpConnection * conn = (MatrixHttpConnection *)client->httpUserData;
+ if (! conn->connected)
+ MatrixHttpConnect(client);
conn->dataReceived = false;
@@ -187,6 +206,8 @@ MatrixHttpPut(
bool authenticated)
{
MatrixHttpConnection * conn = (MatrixHttpConnection *)client->httpUserData;
+ if (! conn->connected)
+ MatrixHttpConnect(client);
conn->dataReceived = false;