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


C++ CompletionContainer类代码示例

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


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

示例1: ReliableSendBaseMsgReply

bool TMsgSocket::ReliableSendBaseMsgReply(unsigned short tagNum, WONMsg::BaseMessage& msg, long timeout,
									 bool async, bool copyData, const CompletionContainer<const SendBaseMsgResult&>& completion)
{
	SendBaseMsgData* sendBaseMsgData = new SendBaseMsgData;
	if (!sendBaseMsgData)
	{
		completion.Complete(SendBaseMsgResult(this, &msg, false, false));
		return false;
	}

	sendBaseMsgData->msg = &msg;
	sendBaseMsgData->completion = completion;

	try {
		msg.Pack();
	}
	catch (...)
	{
		delete sendBaseMsgData;
		completion.Complete(SendBaseMsgResult(this, &msg, false, false));
		return false;
	}

	return ReliableSendRawMsgReplyEx(tagNum, msg.GetDataLen(), msg.GetDataPtr(), timeout, async, copyData, DoneSendBaseMsg, sendBaseMsgData);
}
开发者ID:vgck,项目名称:opendr2,代码行数:25,代码来源:TMsgSocket.cpp

示例2: SendRawMsg

bool TMsgSocket::SendRawMsg(unsigned long length, const void* msg, long timeout, bool async, bool copyData, const CompletionContainer<const SendRawMsgResult&>& completion)
{
	SendMsgData* sendMsgData = new SendMsgData;
	if (!sendMsgData)
	{
		completion.Complete(SendRawMsgResult(this, (unsigned char*)msg, length, false, false));
		return false;
	}
	unsigned char* buffer = (unsigned char*)msg;
	unsigned long newLength = length;
	if (actualSocket->GetType() == stream)
	{
		buffer = new unsigned char[length + lengthSize];
		if (!buffer)
		{
			delete sendMsgData;
			completion.Complete(SendRawMsgResult(this, (unsigned char*)msg, length, false, false));
			return false;
		}
		unsigned long sendLength = length + lengthSize;	// Will only work on a little-endian(?) machine
		makeLittleEndian(sendLength);
		memcpy(buffer, &sendLength, lengthSize);
		memcpy(buffer+lengthSize, msg, length);
		newLength += lengthSize;
	}
	sendMsgData->socketClosed = false;
	sendMsgData->thisSocket = this;
	sendMsgData->success = false;
	sendMsgData->msg = msg;
	sendMsgData->autoDelete = async;
	sendMsgData->length = length;
	sendMsgData->completion = completion;
	
	void (*DoneSendMsgFunc)(const Socket::TransmitResult&, SendMsgData*) = DoneSendMsg;

	actualSocket->SendEx(newLength, buffer, timeout, async, async, DoneSendMsgFunc, sendMsgData);
	
	if (actualSocket->GetType() == stream)
		delete buffer;

	if (async)
		return false;
	
	bool result = sendMsgData->success;

	delete sendMsgData;

	return result;
}
开发者ID:vgck,项目名称:opendr2,代码行数:49,代码来源:TMsgSocket.cpp

示例3: PublisherShutdown

//////////////////////////////////////////////////////////////////////////////
// PublisherShutdown
//
// Method called to shutdown the Publisher client.  Sends message to Observation
// Server to remove this publisher from it's table of publishers.  All publications
// published by this publisher will also be removed.
//
// Returns success or failure on compleation.
//////////////////////////////////////////////////////////////////////////////
Error
ObservationPublisherClient::
PublisherShutdown( const CompletionContainer<const ServerStatus&>& theCompletion, 
				   const ServerStatus* theServerStatusP) // Completion for this operation - Function pointer will be called or event will be signaled when this operation completes
{
	Error aReturn = Error_Success;

	ClientShutdown();

	if (mClientId != 0) 
	{
		MMsgObsRemovePublisher aMsg;

		aMsg.SetPublisherId(mClientId);
		
		aMsg.Pack();

		aReturn = SendMMsgToServer(aMsg, new CompletionContainer<const ServerStatus&>(theCompletion), theServerStatusP);
		mClientId = 0;
		mSocketMgrP->SetClientId(mClientId);
		//delete mSocketMgrP;
		//mSocketMgrP = NULL;
	}
	else // Complete with error
	{
		aReturn = Error_GeneralFailure;
		theCompletion.Complete(StatusObs_UnknownPublisher);
	}

	return aReturn;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:40,代码来源:ObservationAPI.cpp

示例4: Open

Error TMsgSocket::Open(const Address* addr, long timeout, bool async, const CompletionContainer<const Socket::OpenResult&>& completion)
{
	if (!completion.empty())
	{
		IntermediateOpenCompletion* intermediateCompletion = new IntermediateOpenCompletion(this, completion, true);
		intermediateCompletion->completion.OwnCompletion();
		return actualSocket->Open(addr, timeout, async, intermediateCompletion);
	}
	return actualSocket->Open(addr, timeout, async);
}
开发者ID:vgck,项目名称:opendr2,代码行数:10,代码来源:TMsgSocket.cpp

示例5: CatchRecvable

void TMsgSocket::CatchRecvable(const CompletionContainer<const Result&>& completion, bool reuse)
{
	if (!completion.empty())
	{
		IntermediateCompletion* intermediateCompletion = new IntermediateCompletion(this, completion, true);
		intermediateCompletion->completion.OwnCompletion();
		actualSocket->CatchRecvable(intermediateCompletion, reuse);
	}
	else
		actualSocket->CatchRecvable(completion, reuse);
}
开发者ID:vgck,项目名称:opendr2,代码行数:11,代码来源:TMsgSocket.cpp

示例6: Close

void TMsgSocket::Close(long timeout, bool async, const CompletionContainer<const Result&>& completion)
{
	if (!completion.empty())
	{
		IntermediateCompletion* intermediateCompletion = new IntermediateCompletion(this, completion, true);
		intermediateCompletion->completion.OwnCompletion();
		actualSocket->Close(timeout, async, intermediateCompletion);
	}
	else
		actualSocket->Close(timeout, async);
}
开发者ID:vgck,项目名称:opendr2,代码行数:11,代码来源:TMsgSocket.cpp

示例7: ReliableSendRawMsgReply

bool TMsgSocket::ReliableSendRawMsgReply(unsigned short tagNum, unsigned long length, const void* msg, long timeout,
									bool async, bool copyData, const CompletionContainer<const SendRawMsgResult&>& completion)
{
	unsigned char* newMsg = 0;
	ReliableSendRawMsgData* reliableSendRawMsgData;

	if (msg && length && tagNum)
	{
		reliableSendRawMsgData = new ReliableSendRawMsgData;
		if (reliableSendRawMsgData)
		{
			newMsg = new unsigned char[length + 3];
			if (!newMsg)
				delete reliableSendRawMsgData;
		}
	}

	if (!newMsg)
	{
		completion.Complete(SendRawMsgResult(this, (unsigned char*)msg, length, false, false));
		return false;
	}
	
	*(newMsg) = HeaderWithTag;	// 13
	*(unsigned short*)(newMsg+1) = getLittleEndian(tagNum);
	memcpy(newMsg+3, msg, length);

	AutoCrit autoCrit(tagInfoCrit);

	TagNumMap::iterator itor = tagNumMap.find(tagNum);
	if (itor != tagNumMap.end())
	{
		TagInfo* tagInfo = (*itor).second;
		delete tagInfo->msg;
		tagInfo->msg = newMsg;
		tagInfo->msgLength = length + 3;
		reliableSendRawMsgData->newMsg = 0;
	}
	else
	{
		reliableSendRawMsgData->newMsg = newMsg;
		// couldn't find tag in line.  Might have already expired.  Send it anyway
	}

	reliableSendRawMsgData->completion = completion;
	reliableSendRawMsgData->origMsg = (unsigned char*)msg;

	return SendRawMsgEx(length+3, newMsg, timeout, async, false, DoneReliableSendRawMsg, reliableSendRawMsgData);
}
开发者ID:vgck,项目名称:opendr2,代码行数:49,代码来源:TMsgSocket.cpp

示例8: PrizecentralRegisterUser

Error WONAPI::PrizecentralRegisterUser(Identity* ident, const IPSocket::Address* contestServers, unsigned int numAddrs,
								 const SMsgDBRegisterUser& theRegisterUserMsg,
                                 long timeout, bool async, const CompletionContainer<const PrizecentralDBResult&>& completion )
{
	Error err = Error_InvalidParams;
	if (numAddrs)
	{
		err = Error_OutOfMemory;
		PrizecentralData* aPrizecentralData = new PrizecentralData;
		if (aPrizecentralData)
		{
			auto_ptr<PrizecentralData> autoDelPrizecentralData(aPrizecentralData);
			aPrizecentralData->serverList = new IPSocket::Address[numAddrs];
			if (aPrizecentralData->serverList)
			{
				for (int i = 0; i < numAddrs; i++)
					aPrizecentralData->serverList[i] = contestServers[i];
				aPrizecentralData->authSocket.SetIdentity(ident);
				aPrizecentralData->autoDel = async;
				aPrizecentralData->hCompletion = 0;
				aPrizecentralData->completion = completion;
				aPrizecentralData->err = Error_Timeout;
				aPrizecentralData->timeout = timeout;
				aPrizecentralData->curServer = 0;
				aPrizecentralData->numServers = numAddrs;
				aPrizecentralData->req = theRegisterUserMsg;

				autoDelPrizecentralData.release();
				doRegisterUser(aPrizecentralData);

				err = Error_Pending;
				if (!async)
				{
					WSSocket::PumpUntil(aPrizecentralData->doneEvent, timeout);
					//aPrizecentralData->doneEvent.WaitFor();
					err = aPrizecentralData->err;
					delete aPrizecentralData;
				}
				return err;
			}
		}
	}
	completion.Complete(PrizecentralDBResult(err));
	return err;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:45,代码来源:Prizecentral.cpp

示例9: CreateProfile

Error WONAPI::CreateProfile(Identity* identity, const IPSocket::Address* profileServers, unsigned int numAddrs,
                    const char* emailAddress, long timeout, bool async, const CompletionContainer<Error>& completion) 
{
	ProfileData* profileData = new ProfileData;
	if (profileData)
	{
		TCPSocket* tcpSocket = new TCPSocket(profileServers[0]);
		if (tcpSocket)
		{
			profileData->profileSocket = new AuthSocket(identity, tcpSocket, true, 2, false, false);
			if (profileData->profileSocket)
			{
				profileData->emailAddress = emailAddress;
				profileData->error = Error_Timeout;
				profileData->timeout = timeout;
				profileData->autoDelete = async;
//				profileData->dirResultCompletion = completion;

				for (unsigned int i = 0; i < numAddrs; i++)
					profileData->profileServers.push_back(profileServers[i]);
				profileData->curServer = profileData->profileServers.begin();

				SendCreateProfileRequest(profileData, emailAddress);

				Error err = Error_Pending;

				if (!async)
				{
					WSSocket::PumpUntil(profileData->doneEvent, timeout);
					err = profileData->error;
					delete profileData;
				}
				return err;
			}
			delete tcpSocket;
		}
		delete profileData;
	}
	completion.Complete(Error_OutOfMemory);
	return Error_OutOfMemory;
}
开发者ID:vgck,项目名称:opendr2,代码行数:41,代码来源:ProfileAPI.cpp

示例10: SendTo

unsigned long TMsgSocket::SendTo(unsigned long count, const void* buffer, const Address& sendToAddr, long timeout, bool async, bool copyData, const CompletionContainer<const TransmitResult&>& completion)
{
	completion.Complete(TransmitResult(this, (void*)buffer, count, 0, false));
	return 0;
}
开发者ID:vgck,项目名称:opendr2,代码行数:5,代码来源:TMsgSocket.cpp

示例11: RecvFrom

unsigned long TMsgSocket::RecvFrom(unsigned long count, void* buffer, Address* recvFromAddr, long timeout, bool async, const CompletionContainer<const TransmitResult&>& completion)
{
	completion.Complete(TransmitResult(this, buffer, count, 0, false));
	return 0;
}
开发者ID:vgck,项目名称:opendr2,代码行数:5,代码来源:TMsgSocket.cpp

示例12: ReportEvents

Error WONAPI::ReportEvents(Identity* ident, const IPSocket::Address* eventSrvrs, unsigned int numSrvrs,
						   const WONEvent* evts, unsigned int numEvts, bool reliable, bool useUDP,
						   long timeout, long perUDPtimeout, bool async,
						   const CompletionContainer<Error>& completion)
{
	if (!eventSrvrs || !numSrvrs || !evts || !numEvts)
	{
		completion.Complete(Error_InvalidParams);
		return Error_InvalidParams;
	}
	ReportEventsData* reportEventsData = new ReportEventsData;
	if (!reportEventsData)
	{
		completion.Complete(Error_OutOfMemory);
		return Error_OutOfMemory;
	}

	reportEventsData->authSocket = 0;
	reportEventsData->completion = completion;
	reportEventsData->autoDel = async;
	reportEventsData->err = Error_Success;
	reportEventsData->useUDP = useUDP;
	reportEventsData->reliable = reliable;
	reportEventsData->numEvts = numEvts;
	reportEventsData->evtsLeft = numEvts;
	reportEventsData->timeout = timeout;
	reportEventsData->perUDPtimeout = perUDPtimeout;

	for (int curEvt = 0; curEvt < numEvts; curEvt++)
		reportEventsData->evts.push_back(evts[curEvt]);

	for (int i = 0; i < numSrvrs; i++)
		reportEventsData->addrs.push_back(eventSrvrs[i]);
	reportEventsData->addrItor = reportEventsData->addrs.begin();
	
	AuthSocket* authSocket;
	if (useUDP)
	{
		UDPSocket* udpSocket = new UDPSocket(*eventSrvrs);
		if (!udpSocket)
		{
			delete reportEventsData;
			completion.Complete(Error_OutOfMemory);
			return Error_OutOfMemory;
		}
		authSocket = new AuthSocket(ident, udpSocket, true, *eventSrvrs, 4, true, false, false);
		if (!authSocket)
		{
			delete udpSocket;
			delete reportEventsData;
			completion.Complete(Error_OutOfMemory);
			return Error_OutOfMemory;
		}
		reportEventsData->authSocket = authSocket;
	}
	else
	{
		TCPSocket* tcpSocket = new TCPSocket(*eventSrvrs);
		if (!tcpSocket)
		{
			delete reportEventsData;
			completion.Complete(Error_OutOfMemory);
			return Error_OutOfMemory;
		}
		authSocket = new AuthSocket(ident, tcpSocket, true, 4, true, false, false);
		if (!authSocket)
		{
			delete tcpSocket;
			delete reportEventsData;
			completion.Complete(Error_OutOfMemory);
			return Error_OutOfMemory;
		}
		reportEventsData->authSocket = authSocket;
	}
	authSocket->OpenEx(true, timeout, true, ReportEventOpenDone, reportEventsData);

	if (async)
		return Error_Pending;

	WSSocket::PumpUntil(reportEventsData->doneEvent, timeout);
	Error err = reportEventsData->err;
	delete reportEventsData;
	return err;
}
开发者ID:vgck,项目名称:opendr2,代码行数:84,代码来源:EventAPI.cpp

示例13: HTTPGetLL

Error HTTPGetLL(const IPSocket::Address& proxyAddr,
				const std::string& hostName, unsigned short httpPort,
				const std::string& getPath,
				const std::string& saveAsFile, bool allowResume, void* recvBuf, unsigned long* recvBufSize, bool useFile,
				bool* isNew, time_t* modTime, ProgressCallback callback, void* callbackPrivData,
				long timeout, bool async, const CompletionContainer<Error>& completion)
{
	if (getPath.empty() || 
		(useFile	?	(saveAsFile.empty())
					:	(!recvBuf || !recvBufSize || !*recvBufSize)))
	{
		completion.Complete(Error_InvalidParams);
		return Error_InvalidParams;
	}
	
	struct stat fileInfo;
	unsigned long existingSize = 0;
	bool doResume = false;
	time_t localModTime = 0;
	if (modTime)
		localModTime = *modTime;

	if (useFile && allowResume)
	{
		if (!stat(saveAsFile.c_str(), &fileInfo))
		{
		
#if defined(macintosh) && (macintosh == 1)
			fileInfo.st_mtime += 126230400;	// # of seconds Mac time_t differs in stat and utime
#endif

			if (!localModTime)
				localModTime = fileInfo.st_mtime;
			existingSize = fileInfo.st_size;
			if (existingSize)
				doResume = true;
		}
	}

	HTTPGetData* getData = new HTTPGetData;
	if (!getData)
	{
		completion.Complete(Error_OutOfMemory);
		return Error_OutOfMemory;
	}
	getData->existingSize = existingSize;
	getData->callback = callback;
	getData->callbackPrivData = callbackPrivData;
	getData->doResume = doResume;
	getData->modTime = modTime;
	getData->localModTime = localModTime;
	getData->serverModTime = 0;
	getData->getPath = getPath;
	getData->saveAsFile = saveAsFile;
	getData->recvBuf = recvBuf;
	getData->recvBufSize = recvBufSize;
	if (recvBufSize)
	{
		getData->maxRecvBufSize = *recvBufSize;
		*recvBufSize = 0;
	}
	else
		getData->maxRecvBufSize = 0;
	getData->useFile = useFile;
	getData->timeout = timeout;
	getData->autoDel = async;
	getData->proxyAddr = proxyAddr;
	getData->hostName = hostName;
	getData->httpPort = httpPort;
	getData->recvSize = 0;
	getData->isNew = isNew;
	if (isNew)
		*isNew = false;
	getData->completion = completion;
	
	getData->tcpSocket.OpenEx(proxyAddr, timeout, true, DoneHTTPOpen, getData);

	if (async)
		return Error_Pending;

	WSSocket::PumpUntil(getData->doneEvent, timeout);
	Error result = getData->error;
	delete getData;
	return result;
}
开发者ID:vgck,项目名称:opendr2,代码行数:85,代码来源:WONHTTP.cpp

示例14: Done

	void Done()
	{
		completion.Complete(TMsgSocket::RecvBaseMsgResult(thisSocket, msg, socketClosed));

		if (autoDelete)
			delete this;
	}
开发者ID:vgck,项目名称:opendr2,代码行数:7,代码来源:TMsgSocket.cpp

示例15: Complete

void TCPAcceptCompletion::Complete(const WSSocket::AcceptResult& result)
{
	usersCompletion.Complete(result);
	if (!result.acceptedSocket)
		delete acceptSocket;
	Completion<const WSSocket::AcceptResult&>::Complete(result);
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:7,代码来源:TCPSocket.cpp


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