void CDBServConn::_HandleFriendListResponse(CImPduFriendListResponse* pPdu) { uint32_t user_id = pPdu->GetFromUserId(); uint32_t friend_cnt = pPdu->GetFriendCnt(); user_info_t* friend_list = pPdu->GetFriendList(); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); log("HandleFriendListResp, user_id=%d, friend_cnt=%d\n", user_id, friend_cnt); CMsgConn* pToConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle); if (!pToConn || !pToConn->IsOpen()) { return; } CRouteServConn* pRouteConn = get_route_serv_conn(); if (!pRouteConn) { CImPduLoginResponse pduLR(REFUSE_REASON_NO_ROUTE_SERVER); pduLR.SetReserved(pPdu->GetReserved()); pToConn->SendPdu(&pduLR); pToConn->Close(); return; } // transfer from server friend list form to client friend list form (uid->url) CImPduClientFriendList pduCFL(friend_cnt, friend_list); pduCFL.SetReserved(pPdu->GetReserved()); pToConn->SendPdu(&pduCFL); }
void CDBServConn::_HandleDBQueryResponse(CImPduDBQueryResponse* pPdu) { uint32_t user_id = pPdu->GetUserid(); uint32_t seq_no = pPdu->GetSeqNo(); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(user_id, handle); log("HandleDBQueryResp, user_id=%u, seq_no=%u\n", user_id, seq_no); if (pMsgConn && pMsgConn->IsOpen()) { CImPduClientDBQueryResponse pdu(seq_no, pPdu->GetResultLen(), pPdu->GetResultData()); pMsgConn->SendPdu(&pdu); } }
void CRouteServConn::_HandleUsersStatusResponse(CImPduUsersStatusResponse* pPdu) { uint32_t request_id = pPdu->GetRequestId(); uint32_t result_count = pPdu->GetResultCount(); const list<user_stat_t>& result_list = pPdu->GetQueryResult(); log("HandleUsersStatusResp, req_id=%u, query_count=%u\n", request_id, result_count); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); CMsgConn* pToConn = CImUserManager::GetInstance()->GetMsgConnByHandle(request_id,handle); if (pToConn) { CImPduClientUsersStatusResponse pdu(result_list); pToConn->SendPdu(&pdu); } }
void CRouteServConn::_HandleUserStatusResponse(CImPduUserStatusResponse* pPdu) { uint32_t request_id = pPdu->GetRequestId(); uint32_t query_id = pPdu->GetQueryId(); uint32_t status = pPdu->GetStatus(); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); log("HandleUserStatusResp, req_id=%u, query_id=%u, status=%u\n", request_id, query_id, status); CMsgConn* pToConn = CImUserManager::GetInstance()->GetMsgConnByHandle(request_id,handle); if (pToConn) { char* query_id_url = idtourl(query_id); CImPduClientUserStatusResponse pdu(query_id_url, status); pToConn->SendPdu(&pdu); } }
void CDBServConn::_HandleDepartmentResponse(CImPduDepartmentResponse *pPdu) { uint32_t req_user_id = pPdu->GetReqUserId(); uint32_t depart_cnt = pPdu->GetDepartCnt(); department_info_t* depart_list = pPdu->GetDepartList(); log("HandleDepartmentResp, req_user_id=%u, depart_cnt=%u\n", req_user_id, depart_cnt); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(req_user_id, handle); if (pMsgConn && pMsgConn->IsOpen()) { CImPduClientDepartmentResponse pdu(depart_cnt, depart_list); pdu.SetReserved(pPdu->GetReserved()); pMsgConn->SendPdu(&pdu); } }
void CDBServConn::_HandleUnreadMsgCountResponse(CImPduUnreadMsgCountResponse* pPdu) { uint32_t to_user_id = pPdu->GetToUserId(); UserUnreadMsgCnt_t* user_unread_list = pPdu->GetUserUnreadList(); uint32_t user_unread_cnt = pPdu->GetUserUnreadCnt(); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); log("HandleUnreadMsgCntResp, userId=%u, cnt=%u\n", to_user_id, user_unread_cnt); CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(to_user_id, handle); if (pMsgConn && pMsgConn->IsOpen()) { CImPduClientUnreadMsgCntResponse pdu(user_unread_cnt, user_unread_list); pdu.SetReserved(pPdu->GetReserved()); pMsgConn->SendPdu(&pdu); } }
void CFileHandler::HandleClientFileHasOfflineReq(CMsgConn* pMsgConn, CImPduClientFileHasOfflineReq* pPdu) { uint32_t req_user_id = pMsgConn->GetUserId(); log("HandleClientFileHasOfflineReq, req_id=%u\n", req_user_id); CDbAttachData attach_data(ATTACH_TYPE_HANDLE, pMsgConn->GetHandle(), 0); CDBServConn* pDbConn = get_db_serv_conn(); if (pDbConn) { CImPduFileHasOfflineReq pdu(req_user_id, attach_data.GetLength(), attach_data.GetBuffer()); pdu.SetReserved(pPdu->GetReserved()); pDbConn->SendPdu(&pdu); } else { log("warning no DB connection available\n"); CImPduClientFileHasOfflineRes pdu; pdu.SetReserved(pPdu->GetReserved()); pMsgConn->SendPdu(&pdu); } }
void CDBServConn::_HandleRemoveSessionResponse(CImPduRemoveSessionResponse* pPdu) { uint32_t req_user_id = pPdu->GetReqUserId(); uint32_t result = pPdu->GetResult(); uint32_t session_type = pPdu->GetSessionType(); uint32_t session_id = pPdu->GetSessionId(); log("HandleRemoveSessionResp, req_user_id=%u, result=%u, session_id=%u, type=%u\n", req_user_id, result, session_id, session_type); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(req_user_id, handle); if (pMsgConn && pMsgConn->IsOpen()) { char* session_id_url = idtourl(session_id); CImPduClientRemoveSessionResponse pdu(result, session_type, session_id_url); pdu.SetReserved(pPdu->GetReserved()); pMsgConn->SendPdu(&pdu); } }
void CDBServConn::_HandleUsersInfoResponse(CImPduUsersInfoResponse* pPdu) { uint16_t serv_cmd_id = pPdu->GetCommandId(); uint32_t from_user_id = pPdu->GetFromUserId(); uint32_t user_cnt = pPdu->GetUserCnt(); user_info_t* user_info_list = pPdu->GetUserInfoList(); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(from_user_id, handle); log("HandleUsersInfoResp, cmd_id=%u, from_id=%u, user_cnt=%u\n", serv_cmd_id, from_user_id, user_cnt); if (pMsgConn && pMsgConn->IsOpen()) { uint16_t cmd_id = (pPdu->GetCommandId() == IM_PDU_TYPE_USERS_INFO_RESPONSE) ? CID_BUDDY_LIST_USER_INFO_RESPONSE : CID_BUDDY_LIST_ALL_USER_RESPONSE; CImPduClientUserInfoResponse pdu(cmd_id, user_cnt, user_info_list); pdu.SetReserved(pPdu->GetReserved()); pMsgConn->SendPdu(&pdu); } }
void CDBServConn::_HandleMsgListResponse(CImPduMsgListResponse* pPdu) { uint32_t request_cmd_id = pPdu->GetRequestCmdId(); uint32_t from_user_id = pPdu->GetFromUserId(); uint32_t to_user_id = pPdu->GetToUserId(); uint32_t msg_cnt = pPdu->GetMsgCount(); server_msg_t* server_msg_list = pPdu->GetMsgList(); string to_id_url = idtourl(to_user_id); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); uint32_t handle = attach_data.GetHandle(); CMsgConn* pMsgConn = CImUserManager::GetInstance()->GetMsgConnByHandle(from_user_id, handle); log("HandleMsgListResp, req_cmd_id=%u, %u->%u, msg_cnt=%u\n", request_cmd_id, from_user_id, to_user_id, msg_cnt); if (pMsgConn && pMsgConn->IsOpen()) { uint32_t client_cmd_id = CID_MSG_UNREAD_MSG_RESPONSE; CImPduClientMsgListResponse pdu(client_cmd_id, to_id_url.c_str(), msg_cnt, server_msg_list); pdu.SetReserved(pPdu->GetReserved()); pMsgConn->SendPdu(&pdu); } }
static char* build_direct_request(char *meth, struct url *url, char *headers, struct request *rq, int flags) { int rlen, authorization_done = FALSE; char *answer = NULL, *fav=NULL, *httpv, *host=NULL; struct buff *tmpbuff; struct av *av; int host_len=0; int via_inserted = FALSE; // if (!TEST(flags, DONT_CHANGE_HTTPVER) ) { // httpv = "HTTP/1.1"; // if ( TEST(rq->flags, RQ_HAS_HOST) ) // host = rq->url.host; // } else { httpv = url->httpv; if ( !TEST(rq->flags, RQ_HAS_HOST) ) host = rq->url.host; // } tmpbuff = alloc_buff(CHUNK_SIZE); if ( !tmpbuff ) return(NULL); rlen = strlen(meth) + 1/*sp*/ + strlen(url->path) + 1/*sp*/ + strlen(httpv) + 2/* \r\n */; if(TEST(rq->flags,RQ_USE_PROXY)) { rlen=rlen+7+strlen(rq->url.host); if(rq->url.port!=80) rlen=rlen+7; } answer = (char *)xmalloc(ROUND(rlen+1,CHUNK_SIZE), "build_direct_request(): 1"); /* here answer is actually *request* buffer */ if ( !answer ) goto fail; memset(answer,0,rlen+1); if(TEST(rq->flags,RQ_USE_PROXY)) { if(rq->url.port!=80) snprintf(answer,rlen,"%s http://%s:%d%s %s\r\n",meth,rq->url.host,rq->url.port,rq->url.path,httpv); else snprintf(answer,rlen,"%s http://%s%s %s\r\n",meth,rq->url.host,rq->url.path,httpv); } else { sprintf(answer, "%s %s %s\r\n", meth, rq->url.path, httpv); } // printf("host=%s.path=%s.\n",rq->url.host,rq->url.path); // printf("answer=%s.\n",answer); if ( attach_data(answer, strlen(answer), tmpbuff) ) goto fail; if ( headers ) { /* attach what was requested */ if ( attach_data(headers, strlen(headers), tmpbuff) ) goto fail; } host_len=strlen(rq->url.host)+10; host=(char *)malloc(host_len); memset(host,0,host_len); if(rq->url.port!=80) snprintf(host,host_len-1,"%s:%d",rq->url.host,rq->url.port); else snprintf(host,host_len-1,"%s",rq->url.host); if(fav=format_av_pair("Host:",host)) { if(attach_data(fav,strlen(fav),tmpbuff)) goto fail; xfree(fav); fav=NULL; } free(host); av = rq->av_pairs; while ( av ) { if ( is_attr(av, "Proxy-Connection:") ) goto do_not_insert; if ( is_attr(av, "Proxy-Authorization:") ) /* hop-by-hop */ goto do_not_insert; if ( is_attr(av, "Connection:") ) goto do_not_insert; if( is_attr(av,"Host:")) goto do_not_insert; if ( is_attr(av, "Via:") && conf.insert_via && !via_inserted ) { /* attach my Via: */ if ( (fav = format_av_pair(av->attr, av->val)) != 0 ) { char *buf; buf = strchr(fav, '\r'); if ( buf ) *buf = 0; if ( !buf ) { buf = strchr(fav, '\n'); if ( buf ) *buf = 0; } int buf_len=strlen(fav)+2+18+7+10+strlen(VER_ID)+2+1; buf =(char *)malloc(buf_len); if ( !buf ) goto fail; memset(buf,0,buf_len); snprintf(buf,buf_len-1,"%s,%d.%d %s:%d (kingate/%s)\r\n",fav,rq->http_major,rq->http_minor,rq->client->get_server_name() ,conf.port[HTTP], VER_ID); if ( attach_data(buf, strlen(buf), tmpbuff) ) { xfree(buf); goto fail; } via_inserted = TRUE; xfree(buf); xfree(fav); fav = NULL; } goto do_not_insert; } if ( (fav=format_av_pair(av->attr, av->val)) != 0 ) { if ( attach_data(fav, strlen(fav), tmpbuff) ) goto fail; xfree(fav); fav = NULL; } do_not_insert: av = av->next; } if ( (fav = format_av_pair("Connection:", "close")) != 0 ) { if ( attach_data(fav, strlen(fav), tmpbuff) ) goto fail; xfree(fav); fav = NULL; } if(conf.x_forwarded_for) { if( (fav=format_av_pair("X-Forwarded-For:",(char *)rq->server->get_client_name()))!=0) { if ( attach_data(fav, strlen(fav), tmpbuff) ) goto fail; xfree(fav); fav = NULL; } } if (conf.insert_via && !via_inserted ) { char *buf; int buf_len=4+1+18+7+10+strlen(VER_ID)+2+1; buf =(char *) malloc(buf_len); if ( !buf ) goto fail; memset(buf,0,buf_len); snprintf(buf,buf_len-1,"Via: %d.%d %s:%d (kingate/%s)\r\n",rq->http_major,rq->http_minor, rq->client->get_server_name(),conf.port[HTTP], VER_ID); if ( attach_data(buf, strlen(buf), tmpbuff) ) { xfree(buf); goto fail; } xfree(buf); xfree(fav); fav = NULL; } /* CRLF */ if ( attach_data("\r\n", 2, tmpbuff) ) goto fail; if ( attach_data("", 1, tmpbuff) ) goto fail; IF_FREE(answer); answer = tmpbuff->data; tmpbuff->data = NULL; free_chain(tmpbuff); //printf("%s",answer); return answer; fail: IF_FREE(fav); IF_FREE(host); if (tmpbuff) free_chain(tmpbuff); IF_FREE(answer); return NULL; }
int check_server_headers(struct server_answ *a, struct mem_obj *obj, const char *b,int len, struct request *rq) { char *start, *beg, *end, *p; char holder, its_here = 0, off = 2; char *p1 = NULL; a->http_result=0; assert(a); assert(obj); assert(b); assert(rq); sscanf(b,"%*s %d",&a->http_result); // if ( !b || !b->data ) return(0); beg =(char *) b; end = (char *)b + len; if ( end - beg > MAX_DOC_HDR_SIZE ) { /* Header is too large */ return(1); } go: if ( a->state & GOT_HDR ) return(0); start = beg + a->checked; if ( !a->checked ) { p = (char *)memchr(beg, '\n', end-beg); holder = '\n'; if ( !p ) { p = (char *)memchr(beg, '\r', end-beg); holder = '\r'; } if ( !p ) return(0); if ( *p == '\n' ) { if ( *(p-1) == '\r' ) { p1 = p-1; *p1 = 0; } } *p = 0; a->checked = strlen(start); /* this is HTTP XXX yyy "header", which we will never rewrite */ analyze_header(start, a); if ( add_header_av(start, obj) ) { *p = holder; if ( p1 ) { *p1 = '\r'; p1=NULL; } return(-1); } *p = holder; if ( p1 ) { *p1 = '\r'; p1=NULL; } goto go; } if ( (end - start >= 2) && !memcmp(start, "\n\n", 2) ) { its_here = 1; off = 2; } if ( (end - start >= 3) && !memcmp(start, "\r\n\n", 3) ) { its_here = 1; off = 3; } if ( (end - start >= 3) && !memcmp(start, "\n\r\n", 3) ) { its_here = 1; off = 3; } if ( (end - start >= 4) && !memcmp(start, "\r\n\r\n", 4) ) { its_here = 1; off = 4; } if ( its_here ) { struct buff *body; int all_siz; obj->insertion_point = start-beg; obj->tail_length = off; a->state |= GOT_HDR ; obj->httpv_major = a->httpv_major; obj->httpv_minor = a->httpv_minor; obj->content_length = a->content_len; // b->used = ( start + off ) - beg; /* trunc first buf to header siz */ /* if requested don't cache documents without "Last-Modified" */ /* allocate data storage */ if ( a->content_len ) { if ( a->content_len > maxresident ) { /* - This object will not be stored, we will receive it in - small parts, in syncronous mode - allocate as much as we need now... */ all_siz = ROUND_CHUNKS(end-start-off); /* - mark object as 'not for store' and 'don't expand container' */ a->flags |= (ANSW_NO_STORE | ANSW_SHORT_CONTAINER); } else {/* obj is not too large */ all_siz = MIN(a->content_len, 8192); } } else { /* no Content-Len: */ char *transfer_encoding = NULL; all_siz = ROUND_CHUNKS(end-start-off); transfer_encoding = attr_value(obj->headers, "Transfer-Encoding"); if ((transfer_encoding && !strncasecmp("chunked", transfer_encoding, 7)) ) { a->flags |= (ANSW_NO_STORE | ANSW_SHORT_CONTAINER); } } body = alloc_buff(all_siz); if ( !body ) { return(-1); } // b->next = body; obj->container=obj->hot_buff = body; attach_data(start+off, end-start-off, obj->hot_buff); return(0); } p = start; while( (p < end) && ( *p == '\r' || *p == '\n' ) ) p++; if ( p < end && *p ) { char *t = (char *)memchr(p, '\n', end-p); char *tmp, *saved_tmp; holder = '\n'; if ( !t ) { t = (char *)memchr(p, '\r', end-p); holder = '\r'; } if ( !t ) return(0); if ( *t == '\n' ) { if ( *(t-1) == '\r' ) { p1 = t-1; *p1 = 0; } } *t = 0; saved_tmp = tmp = strdup(p); if ( !tmp ) return(-1); // do_redir_rewrite_header(&tmp, rq, NULL); analyze_header(tmp, a); if ( add_header_av(tmp, obj) ) { free(tmp); return(-1); } if ( saved_tmp != tmp ) { /* header was changed */ if ( obj ) SET(obj->flags, ANSW_HDR_CHANGED); } free(tmp); *t = holder; if ( p1 ) { *p1 = '\r'; t=p1; p1 = NULL; } a->checked = t - beg; goto go; } return(0); }
void CHttpQuery::_QueryChangeMember(const string& strAppKey, Json::Value &post_json_obj, CHttpConn *pHttpConn) { HTTP::CDBServConn *pConn = HTTP::get_db_serv_conn(); if (!pConn) { log("no connection to RouteServConn "); char* response_buf = PackSendResult(HTTP_ERROR_SERVER_EXCEPTION, HTTP_ERROR_MSG[9].c_str()); pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf)); pHttpConn->Close(); return; } if ( post_json_obj["req_user_id"].isNull()) { log("no user id "); char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str()); pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf)); pHttpConn->Close(); return; } if ( post_json_obj["group_id"].isNull() ) { log("no group id "); char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str()); pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf)); pHttpConn->Close(); return; } if ( post_json_obj["modify_type"].isNull() ) { log("no modify_type "); char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str()); pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf)); pHttpConn->Close(); return; } if (post_json_obj["user_id_list"].isNull()) { log("no user list "); char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str()); pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf)); pHttpConn->Close(); return; } try { uint32_t user_id = post_json_obj["req_user_id"].asUInt(); uint32_t group_id = post_json_obj["group_id"].asUInt(); uint32_t modify_type = post_json_obj["modify_type"].asUInt(); uint32_t user_cnt = post_json_obj["user_id_list"].size(); log("QueryChangeMember, user_id: %u, group_id: %u, modify type: %u, user_cnt: %u. ", user_id, group_id, modify_type, user_cnt); if (!IM::BaseDefine::GroupModifyType_IsValid(modify_type)) { log("QueryChangeMember, unvalid modify_type"); char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str()); pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf)); pHttpConn->Close(); return; } CDbAttachData attach_data(ATTACH_TYPE_HANDLE, pHttpConn->GetConnHandle()); IM::Group::IMGroupChangeMemberReq msg; msg.set_user_id(0); msg.set_change_type((::IM::BaseDefine::GroupModifyType)modify_type); msg.set_group_id(group_id); for (uint32_t i = 0; i < user_cnt; i++) { uint32_t member_id = post_json_obj["user_id_list"][i].asUInt(); msg.add_member_id_list(member_id); } msg.set_attach_data(attach_data.GetBuffer(), attach_data.GetLength()); CImPdu pdu; pdu.SetPBMsg(&msg); pdu.SetServiceId(IM::BaseDefine::DFFX_SID_GROUP); pdu.SetCommandId(IM::BaseDefine::DFFX_CID_GROUP_CHANGE_MEMBER_REQUEST); pConn->SendPdu(&pdu); } catch (std::runtime_error msg) { log("parse json data failed."); char* response_buf = PackSendResult(HTTP_ERROR_PARMENT, HTTP_ERROR_MSG[1].c_str()); pHttpConn->Send(response_buf, (uint32_t)strlen(response_buf)); pHttpConn->Close(); } }
void CDBServConn::_HandleValidateResponse(CImPduValidateResponse* pPdu) { string user_name(pPdu->GetUserName(), pPdu->GetUserNameLen()); uint32_t result = pPdu->GetResult(); CDbAttachData attach_data(pPdu->GetAttachData(), pPdu->GetAttachLen()); log("HandleValidateResp, user_name=%s, result=%d\n", user_name.c_str(), result); CImUser* pImUser = CImUserManager::GetInstance()->GetImUserByName(user_name); CMsgConn* pMsgConn = NULL; if (!pImUser) { // can not find the client connection, // maybe the client is closed before the DB response arrived // do nothing log("ImUser for user_name=%s not exist\n", user_name.c_str()); return; } else { pMsgConn = pImUser->GetUnValidateMsgConn(attach_data.GetHandle()); if (!pMsgConn || pMsgConn->IsOpen()) { log("no such connection or is validated, user_name=%s\n", user_name.c_str()); return; } } if (result != 0) { result = REFUSE_REASON_DB_VALIDATE_FAILED; } // validate OK, set client validate past, and send FriendListRequest to db storage server // else close the client connection if (result == 0) { user_info_t* user = pPdu->GetUserInfo(); pImUser->SetUser(user); pImUser->SetValidated(); uint32_t user_id = user->user_id; CImUserManager::GetInstance()->AddImUserById(user_id, pImUser); pImUser->KickOutSameClientType(pMsgConn->GetClientType(), pMsgConn); CRouteServConn* pRouteConn = get_route_serv_conn(); if (pRouteConn) { CImPduServerKickUser kickPdu(user_id, pMsgConn->GetClientType(), KICK_REASON_DUPLICATE_USER); pRouteConn->SendPdu(&kickPdu); } string token = create_uuid(); log("user_name: %s, uid: %d, token:%s\n", user_name.c_str(), user->user_id, token.c_str()); pMsgConn->SetToken(token); pMsgConn->SetOpen(); pMsgConn->SendUserActionLog(USER_ACTION_TYPE_LOGIN); pMsgConn->SendUserStatusUpdate(USER_STATUS_ONLINE); pImUser->ValidateMsgConn(token, pMsgConn); CImPduLoginResponse pduLR(result, pImUser->GetIMOnlineStatus(), user, (char*)token.c_str()); pduLR.SetReserved(pPdu->GetReserved()); pMsgConn->SendPdu(&pduLR); } else { CImPduLoginResponse pduLR(result); pduLR.SetReserved(pPdu->GetReserved()); pMsgConn->SendPdu(&pduLR); //pMsgConn->Close(); } }
labworks::LinearDoublyLinkedListNode *labworks::LinearDoublyLinkedListNode::create_new(void * user_data) { auto node = new LinearDoublyLinkedListNode(); node->attach_data(user_data); return node; }