コード例 #1
0
ファイル: vechilemgr.cpp プロジェクト: caocf/workspace-kepler
void CVechileMgr::SendWork()
{
	int ngps = _gps_vec.size() ;

	while( _vechile_inited ) {
		// 检测在线车辆
		int64_t ntime = CheckOnlineUser( ngps ) ;
		if ( ntime <=0 ) {
			continue ;
		}
		usleep( ntime ) ;
	}
}
コード例 #2
0
ファイル: BaseCommand.cpp プロジェクト: ACEZLY/PSS
void CBaseCommand::Do_Ftp_FileUpLoad(IMessage* pMessage)
{
	VCHARS_STR strUserName;
	VCHARM_STR strFilePath;
	VCHARB_STR strFileBuffer(false, VCHARS_TYPE_BINARY);          //文件块信息(二进制模式)
	uint32     u4BlockSize;            //块大小
	uint32     u4CurrBlockIndex;       //当前块ID

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> strUserName;
	(*pBodyPacket) >> strFilePath;
	(*pBodyPacket) >> u4BlockSize;
	(*pBodyPacket) >> u4CurrBlockIndex;
	(*pBodyPacket) >> strFileBuffer;

	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	bool blState = CheckOnlineUser(strUserName.text, pMessage->GetMessageBase()->m_u4ConnectID);
	if(blState == true)
	{
		//获得文件块
		CDirView objDirView;
		uint32 u4BufferCount = 0;
		objDirView.GetFileBufferCount(strFilePath.text, u4BlockSize, u4BufferCount);
		if(u4CurrBlockIndex > u4BufferCount)
		{
			return;
		}

		char* pBuffer = new char[u4BlockSize];

		//接收文件块信息
		ACE_OS::memcpy(pBuffer, strFileBuffer.text, strFileBuffer.u4Len);
		bool blRet = objDirView.SetFileBuffer(strFilePath.text, pBuffer, u4BlockSize, u4CurrBlockIndex);
		if(blRet == true)
		{
			//组成发送包
			IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
			uint16 u2PostCommandID = COMMAND_RETURN_FILE_UPLOAD;

			(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
			(*pResponsesPacket) << (uint32)OP_OK;

			if(NULL != m_pServerObject->GetConnectManager())
			{
				//发送全部数据
				m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
			}
			else
			{
				OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
				m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
			}
		}

		SAFE_DELETE_ARRAY(pBuffer);
	}
	else
	{
		IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
		uint16 u2PostCommandID = COMMAND_RETURN_FILE_UPLOAD;

		(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
		(*pResponsesPacket) << (uint32)OP_FAIL;

		if(NULL != m_pServerObject->GetConnectManager())
		{
			//发送全部数据
			m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
		}
		else
		{
			OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
			m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
		}
	}
}
コード例 #3
0
ファイル: BaseCommand.cpp プロジェクト: ACEZLY/PSS
void CBaseCommand::Do_Ftp_FileList( IMessage* pMessage )
{
	VCHARS_STR strUserName;
	VCHARM_STR strFilePath;

	IBuffPacket* pBodyPacket = m_pServerObject->GetPacketManager()->Create();
	if(NULL == pBodyPacket)
	{
		OUR_DEBUG((LM_ERROR, "[CBaseCommand::DoMessage] pBodyPacket is NULL.\n"));
		return;
	}

	_PacketInfo BodyPacket;
	pMessage->GetPacketBody(BodyPacket);

	pBodyPacket->WriteStream(BodyPacket.m_pData, BodyPacket.m_nDataLen);

	(*pBodyPacket) >> strUserName;
	(*pBodyPacket) >> strFilePath;

	//这里可以添加用户自己的逻辑判定方法
	IBuffPacket* pResponsesPacket = m_pServerObject->GetPacketManager()->Create();
	uint16 u2PostCommandID = COMMAND_RETURN_FILELIST;

	//查看用户有无操作权限
	bool blState = CheckOnlineUser(strUserName.text, pMessage->GetMessageBase()->m_u4ConnectID);
	if(blState == false)
	{
		//返回验证结果
		(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
		(*pResponsesPacket) << (uint32)OP_FAIL;
	}
	else
	{
		(*pResponsesPacket) << (uint16)u2PostCommandID;   //拼接应答命令ID
		(*pResponsesPacket) << (uint32)OP_OK;
		CDirView objDirView;

		//组织文件信息
		vevFileInfo objvevFileInfo;
		objDirView.GetDir(strFilePath.text, objvevFileInfo);
		(*pResponsesPacket) << (uint32)objvevFileInfo.size();
		VCHARS_STR strFileName;
		for(uint32 i = 0; i < (uint32)objvevFileInfo.size(); i++)
		{
			strFileName.text = (char* )objvevFileInfo[i].m_szFileName;
			strFileName.u1Len = (uint8)ACE_OS::strlen(objvevFileInfo[i].m_szFileName);
			(*pResponsesPacket) << strFileName;
			(*pResponsesPacket) << objvevFileInfo[i].m_u4FileType;
			(*pResponsesPacket) << objvevFileInfo[i].m_u4FileSize;
		}
	}


	m_pServerObject->GetPacketManager()->Delete(pBodyPacket);

	if(NULL != m_pServerObject->GetConnectManager())
	{
		//发送全部数据
		m_pServerObject->GetConnectManager()->PostMessage(pMessage->GetMessageBase()->m_u4ConnectID, pResponsesPacket, SENDMESSAGE_NOMAL, u2PostCommandID, PACKET_SEND_IMMEDIATLY, PACKET_IS_FRAMEWORK_RECYC);
	}
	else
	{
		OUR_DEBUG((LM_INFO, "[CBaseCommand::DoMessage] m_pConnectManager = NULL"));
		m_pServerObject->GetPacketManager()->Delete(pResponsesPacket);
	}
}