当前位置: 首页>>代码示例>>C++>>正文


C++ Hero::getFd方法代码示例

本文整理汇总了C++中Hero::getFd方法的典型用法代码示例。如果您正苦于以下问题:C++ Hero::getFd方法的具体用法?C++ Hero::getFd怎么用?C++ Hero::getFd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hero的用法示例。


在下文中一共展示了Hero::getFd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: acceptCdkeySrv

//解析从cdkey Server返回的消息
void acceptCdkeySrv(char *buffer)
{
	if (sock_fd != cdKeySrvFd)
	{
		return;
	}
	cout<<"the sizeof buff:"<<strlen(buffer)<<endl;
	
	char *userName;
	char *cdKeyId;
	char *heroId;
	char failReason[100] = {0};
	char *flag;
	MSG_BEGIN(buffer,g_msg_len);
	// MSG_CHAR(userName);
	MSG_CHAR(heroId);
	// MSG_CHAR(cdKeyId);
	// MSG_CHAR_END(flag);
	
	Hero *myHero = heroid_to_hero(heroId);
	
	if(myHero == NULL)
	{
		cout<<"the hero is NUll:"<<heroId<<endl;
		return;
	}
	
	
	cout<<"userName:"<<userName<<endl;
	cout<<"heroId:"<<heroId<<endl;
	cout<<"cdKeyId:"<<cdKeyId<<endl;
	cout<<"flag:"<<flag<<endl;
	
	
	if(strncmp(flag,"0",1) == 0)
	{
		/*激活码错误*/
		snprintf(failReason,sizeof(failReason),"%d,%d,0",28,3);
		send_msg(myHero->getFd(),failReason); 	
		cout<<"the activeCodeId is error:"<<cdKeyId<<endl;
	}	
	else if(strncmp(flag,"1",1) == 0)
	{
		/*激活码已被使用*/
		snprintf(failReason,sizeof(failReason),"%d,%d,1",28,3);
		send_msg(myHero->getFd(),failReason); 	
		cout<<"the activeCodeId is used by other:"<<cdKeyId<<endl;
	}	
	//已使用激活码
	else if(strncmp(flag,"2",1) == 0)
	{
		snprintf(failReason,sizeof(failReason),"%d,%d,2",28,3);
		send_msg(myHero->getFd(),failReason); 	
	}	
	
}
开发者ID:cirosantilli,项目名称:netWork-fork,代码行数:57,代码来源:acceptActiveCode.cpp

示例2: acceptCdkeySrvSuccess

//解析从cdkey Server返回的消息
void acceptCdkeySrvSuccess(char *buffer)
{
	if (sock_fd != cdKeySrvFd)
	{
		return;
	}
	cout<<"the sizeof buff:"<<strlen(buffer)<<endl;
	char *userName;
	char *cdKeyId;
	char *heroId;
	char *goodsId;
	char *type;
	char failReason[100] = {0};
	int flag = 0;
	
	MSG_BEGIN(buffer,g_msg_len);
	MSG_CHAR(userName);
	MSG_CHAR(heroId);
	MSG_CHAR(cdKeyId);
	MSG_CHAR(goodsId);	
	MSG_CHAR_END(type);
	
	
	Hero *myHero = heroid_to_hero(heroId);
	
	if(myHero == NULL)
	{
		cout<<"the hero is NUll:"<<heroId<<endl;
		return;
	}
	if(type[0] == '0')
	{
		myHero->useActiveCode(cdKeyId,0);
	}
	else
	{
		myHero->useActiveCode(cdKeyId,1);
	}
	
	/*成功激活验证码*/
	snprintf(failReason,sizeof(failReason),"%d,%d,3",28,3);
	
	send_msg(myHero->getFd(),failReason);		
	
	saveGoodsInBag(myHero,goodsId,1);
	
	char account_msg[1024]={'\0'};
	snprintf(account_msg,sizeof(account_msg),"%d,%d,%s,%d,%s,%s,%s,%s",20,0,server_name,(int)myTime.tv_sec,myHero->getIdentity(),myHero->getNickName(),pg_role->getUserName(),cdKeyId);
	write_log(account_msg);	
	
}
开发者ID:cirosantilli,项目名称:netWork-fork,代码行数:52,代码来源:acceptActiveCode.cpp


注:本文中的Hero::getFd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。