Browse Source

fix: websocket库在conack完成前,应禁止用户上传数据

Wendal Chen 3 years ago
parent
commit
5a54862e1d
1 changed files with 6 additions and 0 deletions
  1. 6 0
      components/network/websocket/luat_lib_websocket.c

+ 6 - 0
components/network/websocket/luat_lib_websocket.c

@@ -328,6 +328,12 @@ static int l_websocket_send(lua_State *L)
 		.OPT_CODE = 0x01,
 		.plen = payload_len,
 		.payload = payload};
+	
+	if (websocket_ctrl->websocket_state != 1) {
+		LLOGI("not ready yet");
+		lua_pushboolean(L, 0);
+		return 1;
+	}
 	ret = luat_websocket_send_frame(websocket_ctrl, &pkg);
 	lua_pushboolean(L, ret == 0 ? 1 : 0);
 	return 1;