feat(ncm): 登录流程关键节点日志(unikey/轮询状态迁移/803落cookie/poll失败)便于真机联调
This commit is contained in:
1 parent
7c75bb52dd
commit
f806395dbe
2 files changed
+7
-2
No files matched your search
@@ -78,7 +78,8 @@ static int get_unikey_and_qr(char *unikey, size_t usz)
|
|||||||
|
|
||||||
{
|
{
|
||||||
int rc = ncm_login_unikey(g_st.ctx.device_id, unikey, usz);
|
int rc = ncm_login_unikey(g_st.ctx.device_id, unikey, usz);
|
||||||
if (rc != NCM_OK) return rc;
|
if (rc != NCM_OK) { meow_log(MEOW_LOG_ERROR, "login: unikey fetch failed rc=%d", rc); return rc; }
|
||||||
|
meow_log(MEOW_LOG_INFO, "login: unikey ok, qr ready");
|
||||||
ncm_strlcpy(g_st.unikey, unikey, sizeof g_st.unikey);
|
ncm_strlcpy(g_st.unikey, unikey, sizeof g_st.unikey);
|
||||||
ncm_login_qr_url(unikey, g_st.qr_url, sizeof g_st.qr_url);
|
ncm_login_qr_url(unikey, g_st.qr_url, sizeof g_st.qr_url);
|
||||||
int size = 0;
|
int size = 0;
|
||||||
@@ -96,6 +97,7 @@ static void *login_worker(void *arg)
|
|||||||
(void)arg;
|
(void)arg;
|
||||||
char unikey[64];
|
char unikey[64];
|
||||||
if (get_unikey_and_qr(unikey, sizeof unikey) != NCM_OK) { g_err = 1; return NULL; }
|
if (get_unikey_and_qr(unikey, sizeof unikey) != NCM_OK) { g_err = 1; return NULL; }
|
||||||
|
meow_log(MEOW_LOG_INFO, "login: poll worker start");
|
||||||
|
|
||||||
char cookie[NCM_COOKIE_MAX];
|
char cookie[NCM_COOKIE_MAX];
|
||||||
ncm_strlcpy(cookie, g_st.ctx.cookie, sizeof cookie);
|
ncm_strlcpy(cookie, g_st.ctx.cookie, sizeof cookie);
|
||||||
@@ -105,10 +107,13 @@ static void *login_worker(void *arg)
|
|||||||
char out_cookie[NCM_COOKIE_MAX];
|
char out_cookie[NCM_COOKIE_MAX];
|
||||||
int rc = ncm_login_poll(g_st.ctx.device_id, unikey, cookie, &r,
|
int rc = ncm_login_poll(g_st.ctx.device_id, unikey, cookie, &r,
|
||||||
out_cookie, sizeof out_cookie);
|
out_cookie, sizeof out_cookie);
|
||||||
if (rc != NCM_OK) { g_err = 1; usleep(2 * 1000 * 1000); continue; }
|
if (rc != NCM_OK) { meow_log(MEOW_LOG_WARN, "login: poll failed rc=%d", rc); g_err = 1; usleep(2 * 1000 * 1000); continue; }
|
||||||
|
if (r.state != g_st.login_state)
|
||||||
|
meow_log(MEOW_LOG_INFO, "login: state -> %d", (int)r.state);
|
||||||
g_st.login_state = r.state;
|
g_st.login_state = r.state;
|
||||||
|
|
||||||
if (r.state == NCM_LOGIN_OK) {
|
if (r.state == NCM_LOGIN_OK) {
|
||||||
|
meow_log(MEOW_LOG_INFO, "login: 803 confirmed, saving cookie");
|
||||||
ncm_strlcpy(cookie, out_cookie, sizeof cookie);
|
ncm_strlcpy(cookie, out_cookie, sizeof cookie);
|
||||||
ncm_ctx_set_cookie(&g_st.ctx, cookie);
|
ncm_ctx_set_cookie(&g_st.ctx, cookie);
|
||||||
/* 拿 uid/nickname */
|
/* 拿 uid/nickname */
|
||||||
|
|||||||
Binary file not shown.
Reference in new issue
Block a user