本文整理汇总了C++中CBuffer::Receive方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::Receive方法的具体用法?C++ CBuffer::Receive怎么用?C++ CBuffer::Receive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::Receive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessPendingRead
void CAuctionServerDoc::ProcessPendingRead(CClientSocket* pSocket)
{
CBuffer buffer;
int nLen = buffer.Receive(pSocket);
CString str;
switch (buffer.GetCmd())
{
case CMD_REGISTER_CLIENT:
{
CInRegisterClient* inBuf = (CInRegisterClient*)&buffer;
CString strUserID = inBuf->GetUserID();
CString strPassword = inBuf->GetUserPassword();
CString strUserName;
bool bValidUser = ValidateUser(strUserID, strPassword, strUserName);
pSocket->SetUserID(strUserID);
UpdateClientUserID(pSocket, strUserID);
COutRegisterClient outBuf;
outBuf.SetValid(bValidUser);
if (bValidUser)
{
outBuf.SetUserName(strUserName);
pSocket->SetUserName(strUserName);
UpdateClientName(pSocket, strUserName);
outBuf.SetLogin(CheckLogin(strUserID));
UpdateClientLogin(pSocket, true);
}
outBuf.Send(pSocket);
str.Format(TEXT("CMD_REGISTER_CLIENT") );
m_listMessage.Push(str);
str.Format(TEXT("\tUserID = %s, UserName = %s"), strUserID, strUserName);
m_listMessage.Push(str);
m_stateAuction = E_NONE;
}
break;
case CMD_RETRIEVE_STOCK_OF_CLIENT:
{
CInRetrieveStock* inBuf = (CInRetrieveStock*)&buffer;
CString strUserID = inBuf->GetUserID();
std::vector<CProduct> & listProduct = GetListProduct(strUserID);
COutRetrieveStock outBuf;
outBuf.SetListProduct(listProduct);
str.Format(TEXT("CMD_RETRIEVE_STOCK_OF_CLIENT") );
m_listMessage.Push(str);
for (CProduct product : listProduct)
{
str.Format(TEXT(">>>ProductID = %d, ProductCount = %d,Price = %f, Product Name = %s"),
product.GetProductID(),
product.GetCount(),
product.GetPrice(),
product.GetName());
m_listMessage.Push(str);
}
outBuf.Send(pSocket);
m_stateAuction = E_NONE;
}
break;
case CMD_ADVERTISING:
{
str.Format(TEXT("CMD_ADVERTISING"));
m_listMessage.Push(str);
m_stateAuction = E_ADVERTISING;
CInAdvertising* inBuf = (CInAdvertising*)&buffer;
DWORD dwProductID = inBuf->GetProductID();
CString strName = inBuf->GetProductName();
DWORD dwCount = inBuf->GetProductCount();
double dblPrice = inBuf->GetProductPrice();
CBroadcastPrice buf;
buf.SetProductID(dwProductID);
buf.SetProductCount(dwCount);
buf.SetProductPrice(dblPrice);
buf.SetProductName(strName);
str.Format(TEXT("Broadcast Advertising Event. (%s, %d, %f)"), strName, dwCount, dblPrice);
m_listMessage.Push(str);
// Broadcast this packet to the other clients
BroadcastBuffer( buf);
COutAdvertising outBuf;
outBuf.SetState(m_stateAuction);
outBuf.Send(pSocket);
//.........这里部分代码省略.........