From 6c03a6605febb89590e3355138b6917429cc19ca Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 24 Mar 2020 20:28:57 +0900 Subject: [PATCH] Fix issue request sending fail log is displayed before connection is established Change-Id: I655ef74f51c62c82a4c476b9b2fabb2faee774f3 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 4a2ec79..cc821a9 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -273,7 +273,18 @@ void accept_file() void request_sticker_data(const char *mode, const char *category, const char *type) { - JsonObject *j_object = json_object_new(); + JsonObject *j_object = NULL; + if (!priv_data.socket) { + pending_request.req_type = REQUEST_TYPE_SYNC; + pending_request.mode = string(mode ? mode : "manual"); + pending_request.category = string(category? category : "arsticker"); + pending_request.type = string(type ? type : "input"); + + LOGI("Push sync request"); + return; + } + + j_object = json_object_new(); if (j_object == NULL) { LOGE("json object create error"); return; @@ -286,12 +297,7 @@ void request_sticker_data(const char *mode, const char *category, const char *ty json_object_set_string_member(j_object, "type", type); if (_send_json_data(j_object) == FALSE) { - pending_request.req_type = REQUEST_TYPE_SYNC; - pending_request.mode = string(mode ? mode : "manual"); - pending_request.category = string(category? category : "arsticker"); - pending_request.type = string(type ? type : "input"); - - LOGI("Push sync request"); + LOGE("Failed to send STICKER_SYNC_START_REQ"); } else { current_request.req_type = REQUEST_TYPE_SYNC; @@ -305,7 +311,15 @@ void request_sticker_data(const char *mode, const char *category, const char *ty void request_sticker_feature() { - JsonObject *j_object = json_object_new(); + JsonObject *j_object = NULL; + + if (!priv_data.socket) { + pending_request.req_type = REQUEST_TYPE_FEATURE_REQ; + LOGI("Push sync feature request"); + return; + } + + j_object = json_object_new(); if (j_object == NULL) { LOGE("json object create error"); return; @@ -315,7 +329,6 @@ void request_sticker_feature() json_object_set_int_member(j_object, "tID", ++t_id); if (_send_json_data(j_object) == FALSE) { - pending_request.req_type = REQUEST_TYPE_FEATURE_REQ; LOGE("Failed to send STICKER_SYNC_FEATURE_REQ"); } -- 2.7.4