{
VAD_UNUSED(para); VAD_UNUSED(paraLen); VAD_UNUSED(strCommonCmd);
printf("[LN][WS_STOP]\n");
- int ret = ln_ws_stop();
+ int ret = ln_ws_stop_async();
if (ret != 0)
{
printf("[LN][WS_STOP] failed: %d\n", ret);
static void ln_ws_on_close(int client)
{
(void)client;
- printf("WebSocketClientConstructor [LN][WS] ln_ws_on_close");
+ printf("WebSocketClientConstructor [LN][WS] ln_ws_on_close %d\r\n",client);
g_ws_connected = WS_STATE_DISCONNECTED;
printf("[LN][WS] 连接状态: 未连接\n");
if(g_ws_client_fd>=0)
/* 1秒间隔 */
usleep(1000 * 1000);
}
+
+ if (g_ws_client_fd >= 0) {
+ WebSocketClientClose(g_ws_client_fd);
+ g_ws_client_fd = -1;
+ }
+ g_ws_connected = WS_STATE_DISCONNECTED;
+
+ // 删除消息队列
+ if (g_ws_msg_queue != NULL) {
+
+ ws_msg_info_t msg;
+ while (osMessageQueueGet(g_ws_msg_queue, &msg, NULL, 0) == osOK) {
+ if(msg.data.raw_json)
+ {
+ free(msg.data.raw_json);
+ }
+
+ }
+ osMessageQueueDelete(g_ws_msg_queue);
+ g_ws_msg_queue = NULL;
+ }
}
/*
ws_msg_info_t msg;
msg.msg_type = WS_MSG_TYPE_FORCE_RECONNECT;
msg.data_len = 0;
- // msg.data = NULL;
+ msg.data.raw_json = NULL;
osStatus_t ret = osMessageQueuePut(g_ws_msg_queue, &msg, 0, 0);
return (ret == osOK) ? 0 : -1;
ws_msg_info_t msg;
msg.msg_type = WS_MSG_TYPE_STOP;
msg.data_len = 0;
+ msg.data.raw_json = NULL;
// msg.data = NULL;
osStatus_t ret = osMessageQueuePut(g_ws_msg_queue, &msg, 0, 0);