conn->dataLen = hm->body.len;\r
conn->dataReceived = true;\r
\r
- printf("received[%d]:\n%.*s\n", conn->dataLen, conn->dataLen, conn->data);\r
+ //printf("received[%d]:\n%.*s\n", conn->dataLen, conn->dataLen, conn->data);\r
+ }\r
+ if (ev == MG_EV_CLOSE)\r
+ {\r
+ conn->connection = NULL;\r
+ conn->connected = false;\r
}\r
}\r
\r
\r
mg_mgr_init(&conn->mgr);\r
\r
- struct mg_connection * c =\r
+ return MatrixHttpConnect(client);\r
+}\r
+\r
+bool\r
+MatrixHttpConnect(\r
+ MatrixClient * client)\r
+{\r
+ MatrixHttpConnection * conn =\r
+ (MatrixHttpConnection *)client->httpUserData;\r
+ \r
+ //struct mg_connection * c =\r
mg_http_connect(&conn->mgr, client->server, MatrixHttpCallback, client);\r
\r
while (! conn->connected)\r
bool authenticated)\r
{\r
MatrixHttpConnection * conn = (MatrixHttpConnection *)client->httpUserData;\r
+ if (! conn->connected)\r
+ MatrixHttpConnect(client);\r
\r
conn->dataReceived = false;\r
\r
bool authenticated)\r
{\r
MatrixHttpConnection * conn = (MatrixHttpConnection *)client->httpUserData;\r
+ if (! conn->connected)\r
+ MatrixHttpConnect(client);\r
\r
conn->dataReceived = false;\r
\r
bool authenticated)\r
{\r
MatrixHttpConnection * conn = (MatrixHttpConnection *)client->httpUserData;\r
+ if (! conn->connected)\r
+ MatrixHttpConnect(client);\r
\r
conn->dataReceived = false;\r
\r
else\r
authorizationHeader[0] = '\0';\r
\r
- printf("PUT %s HTTP/1.0\r\n"\r
- "Host: %.*s\r\n"\r
- "%s"\r
- "Content-Type: application/json\r\n"\r
- "Content-Length: %d\r\n"\r
- "\r\n"\r
- "%s"\r
- "\r\n",\r
- url,\r
- host.len, host.ptr,\r
- authorizationHeader,\r
- strlen(requestBuffer),\r
- requestBuffer);\r
-\r
mg_printf(conn->connection,\r
"PUT %s HTTP/1.0\r\n"\r
"Host: %.*s\r\n"\r