|
@@ -52,6 +52,25 @@ int wpoc_login_req(OEM_sock *handle, unsigned int psn, char *pass,char *hardid,c
|
|
|
rlen=OEM_sys_sock_send_data(handle, out, outsize);
|
|
|
return rlen;
|
|
|
}
|
|
|
+int wpoc_query_group_req(OEM_sock *handle){
|
|
|
+ wlog_info("try query group");
|
|
|
+ QueryGroup _querygroup=QUERY_GROUP__INIT;
|
|
|
+ _querygroup.detail=QUERY_GROUP__DETAIL_LEVEL__ALL_INFO;
|
|
|
+ _querygroup.has_max_groups=true;
|
|
|
+ wpoc_app.groupList.usrSetMaxGroupNum=wpoc.maxGroupNum;
|
|
|
+ _querygroup.max_groups=wpoc_app.groupList.usrSetMaxGroupNum;
|
|
|
+ int rlen=query_group__get_packed_size(&_querygroup);
|
|
|
+ unsigned char *pb=(unsigned char *)malloc(rlen+1);
|
|
|
+ if(pb==NULL) return -1;
|
|
|
+ rlen=query_group__pack(&_querygroup, pb+1);
|
|
|
+ int outsize;
|
|
|
+ unsigned char *out=w_packing_buf(&outsize, U_QUERY_GROUP, pb, rlen+1);
|
|
|
+ free(pb);
|
|
|
+ if(out==NULL) return -2;
|
|
|
+
|
|
|
+ rlen=OEM_sys_sock_send_data(handle, out, outsize);
|
|
|
+ return rlen;
|
|
|
+}
|
|
|
int wpoc_ping_req(OEM_sock *handle,bool need_time_ack){
|
|
|
wlog_info("try ping req:%s", need_time_ack==true?"with time":"no time");
|
|
|
Ping _ping=PING__INIT;
|
|
@@ -205,16 +224,66 @@ void w_unpacking_buf(unsigned char *usrbuf, int usrsize){
|
|
|
static void d_login_ack(const ProtobufCMessage *msg){
|
|
|
LoginAck *ack=(LoginAck *)msg;
|
|
|
if(ack->result!=0){
|
|
|
- wlog_warn("login fail");
|
|
|
+ wlog_warn("login fail:%d",ack->result);
|
|
|
return;
|
|
|
}
|
|
|
- wlog_warn("login ok");
|
|
|
+ wlog_warn("login ok:port=%d",ack->confi->talk_port);
|
|
|
wpoc_app.poc_login=1;
|
|
|
wpoc_app.poc_firstLogin=1;
|
|
|
- wpoc_que_data_send(WPOC_QUE_DATA_RX_LOGINACK, NULL, 0);
|
|
|
+ wpoc_app.poc_voice_port=ack->confi->talk_port;
|
|
|
+ WPOC_LOGINACK_DEF uinfo;
|
|
|
+ uinfo.user_id=ack->usr->id;
|
|
|
+ snprintf(uinfo.user_name, sizeof(uinfo.user_name), "%s", ack->usr->name);
|
|
|
+ uinfo.be_group_id=ack->currg_group->id;
|
|
|
+ snprintf(uinfo.be_group_name, sizeof(uinfo.be_group_name), "%s", ack->currg_group->name);
|
|
|
+ uinfo.user_num_in_group=ack->currg_group->umembers;
|
|
|
+ wpoc_que_data_send(WPOC_QUE_DATA_RX_LOGINACK, &uinfo, sizeof(WPOC_LOGINACK_DEF));
|
|
|
+ wpoc_que_data_send(WPOC_QUE_DATA_TX_QUERY_GROUP, NULL, 0);
|
|
|
}
|
|
|
static void d_query_group_ack(const ProtobufCMessage *msg){
|
|
|
QueryGroupAck *ack=(QueryGroupAck *)msg;
|
|
|
+ if(ack->result!=0){
|
|
|
+ wlog_warn("query group fail:%d", ack->result);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ wlog_info("query group ok:%u", ack->n_groups);
|
|
|
+ int i;
|
|
|
+ unsigned int num;
|
|
|
+ GROUP_INFO_LIST *gInfo=&wpoc_app.groupList;
|
|
|
+ if(gInfo->usrSetMaxGroupNum==0) gInfo->usrSetMaxGroupNum=100;
|
|
|
+ if(gInfo->groupInfo==NULL || gInfo->maxGroupNum!=gInfo->usrSetMaxGroupNum){
|
|
|
+ if(gInfo->groupInfo!=NULL){
|
|
|
+ for(i=0;i<gInfo->maxGroupNum;i++) OEM_sys_free(gInfo->groupInfo[i]);
|
|
|
+ OEM_sys_free(gInfo->groupInfo);
|
|
|
+ //try to new
|
|
|
+ num=gInfo->usrSetMaxGroupNum;
|
|
|
+ gInfo->groupInfo=(GROUP_INFO_DEF **)OEM_sys_malloc(num*sizeof(GROUP_INFO_DEF*));
|
|
|
+ if(gInfo->groupInfo==NULL){
|
|
|
+ wlog_error("groupInfo new fail");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for(i=0;i<num;i++){
|
|
|
+ gInfo->groupInfo[i]=(GROUP_INFO_DEF *)OEM_sys_malloc(sizeof(GROUP_INFO_DEF));
|
|
|
+ if(gInfo->groupInfo[i]==NULL){
|
|
|
+ wlog_error("groupInfo new no enough:%d,%d", i, num);
|
|
|
+ for(num=0;i<i;i++) OEM_sys_free(gInfo->groupInfo[i]);
|
|
|
+ OEM_sys_free(gInfo->groupInfo);
|
|
|
+ gInfo->groupInfo=NULL;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //start to save
|
|
|
+ gInfo->maxGroupNum=gInfo->usrSetMaxGroupNum;
|
|
|
+ num=(ack->n_groups>gInfo->maxGroupNum?gInfo->maxGroupNum:ack->n_groups);
|
|
|
+ for(i=0;i<num;i++){
|
|
|
+ wlog_info("group<%d>id=%08x,mem=%d,name=%s", i,ack->groups[i]->id, ack->groups[i]->umembers,ack->groups[i]->name);
|
|
|
+ gInfo->groupInfo[i]->id=ack->groups[i]->id;
|
|
|
+ gInfo->groupInfo[i]->mem_num=ack->groups[i]->umembers;
|
|
|
+ snprintf(gInfo->groupInfo[i]->name,sizeof(gInfo->groupInfo[i]->name), "%s", ack->groups[i]->name);
|
|
|
+ }
|
|
|
+ gInfo->validGroupNum=num;
|
|
|
+ }
|
|
|
}
|
|
|
static void d_join_group_ack(const ProtobufCMessage *msg){
|
|
|
JoinGroupAck *ack=(JoinGroupAck *)msg;
|
|
@@ -264,7 +333,9 @@ void w_poc_cmd_que_tx_login(void *param1){
|
|
|
};
|
|
|
wpoc_que_data_send(WPOC_QUE_DATA_TX_LOGIN, &usrdata, sizeof(WPOC_CMD_DATA_DEF));
|
|
|
}
|
|
|
-
|
|
|
+void w_poc_cmd_que_tx_query_group(void){
|
|
|
+ wpoc_que_data_send(WPOC_QUE_DATA_TX_QUERY_GROUP, NULL, 0);
|
|
|
+}
|
|
|
void w_poc_cmd_que_tx_ping(unsigned int value){
|
|
|
WPOC_CMD_DATA_DEF usrdata={
|
|
|
.data1=value
|