|  | @@ -766,87 +766,93 @@ void CIOCPModel::_ShowMessage(const CString szFormat,...) const
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#define PAK_LEN sizeof(_PACKAGE_)
 | 
	
		
			
				|  |  | +#define PAK_LEN sizeof(ProHeader)
 | 
	
		
			
				|  |  |  void CIOCPModel::_RecvProcess(PER_SOCKET_CONTEXT* pSocketContext, PER_IO_CONTEXT* pIoContext)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  | -	int plen = sizeof(_PACKAGE_);
 | 
	
		
			
				|  |  |  	// 鬼黨관庫;
 | 
	
		
			
				|  |  |  	ProHeader* phead = NULL;
 | 
	
		
			
				|  |  |  	if (pSocketContext->lastData.size() == 0)
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  | -		phead = (ProHeader*)pIoContext->m_wsaBuf.buf;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		// 供냥돨관;
 | 
	
		
			
				|  |  | -		if (phead->len == pIoContext->m_wsaBuf.len)
 | 
	
		
			
				|  |  | -		{
 | 
	
		
			
				|  |  | -			_DeviceProc(pSocketContext, (Package*)pIoContext->m_wsaBuf.buf);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		// 鬼관;
 | 
	
		
			
				|  |  | -		else if (phead->len < pIoContext->m_wsaBuf.len)
 | 
	
		
			
				|  |  | +		if (PAK_LEN > pIoContext->m_Overlapped.InternalHigh)
 | 
	
		
			
				|  |  |  		{
 | 
	
		
			
				|  |  | -			pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_wsaBuf.len);
 | 
	
		
			
				|  |  | +			pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		// 낚관;
 | 
	
		
			
				|  |  | -		else if (phead->len > pIoContext->m_wsaBuf.len)
 | 
	
		
			
				|  |  | +		else
 | 
	
		
			
				|  |  |  		{
 | 
	
		
			
				|  |  | -			_DeviceProc(pSocketContext, (Package*)pIoContext->m_wsaBuf.buf);
 | 
	
		
			
				|  |  | -			pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + phead->len, pIoContext->m_wsaBuf.len - phead->len);
 | 
	
		
			
				|  |  | +			phead = (ProHeader*)pIoContext->m_wsaBuf.buf;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			// 供냥돨관;
 | 
	
		
			
				|  |  | +			if (phead->len == pIoContext->m_Overlapped.InternalHigh)
 | 
	
		
			
				|  |  | +			{
 | 
	
		
			
				|  |  | +				_DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			// 鬼관;
 | 
	
		
			
				|  |  | +			else if (phead->len > pIoContext->m_Overlapped.InternalHigh)
 | 
	
		
			
				|  |  | +			{
 | 
	
		
			
				|  |  | +				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			// 낚관;
 | 
	
		
			
				|  |  | +			else if (phead->len < pIoContext->m_Overlapped.InternalHigh)
 | 
	
		
			
				|  |  | +			{
 | 
	
		
			
				|  |  | +				_DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
 | 
	
		
			
				|  |  | +				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + phead->len, pIoContext->m_Overlapped.InternalHigh - phead->len);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	else
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  | -		int lastlen = pIoContext->m_wsaBuf.len;
 | 
	
		
			
				|  |  | +		int lastlen = pIoContext->m_Overlapped.InternalHigh;
 | 
	
		
			
				|  |  |  		if (pSocketContext->lastData.size() >= PAK_LEN)
 | 
	
		
			
				|  |  |  		{
 | 
	
		
			
				|  |  |  			phead = (ProHeader*)pSocketContext->lastData.data();
 | 
	
		
			
				|  |  | -			if (phead->len <= pSocketContext->lastData.size() + pIoContext->m_wsaBuf.len)
 | 
	
		
			
				|  |  | +			if (phead->len <= pSocketContext->lastData.size() + pIoContext->m_Overlapped.InternalHigh)
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  | -				lastlen = pSocketContext->lastData.size() + pIoContext->m_wsaBuf.len - phead->len;
 | 
	
		
			
				|  |  | -				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, lastlen);
 | 
	
		
			
				|  |  | +				lastlen = pSocketContext->lastData.size() + pIoContext->m_Overlapped.InternalHigh - phead->len;
 | 
	
		
			
				|  |  | +				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh - lastlen);
 | 
	
		
			
				|  |  |  				// 供憐관;
 | 
	
		
			
				|  |  | -				_DeviceProc(pSocketContext, (Package*)pSocketContext->lastData.data());
 | 
	
		
			
				|  |  | +				_DeviceProc(pIoContext, (Package*)pSocketContext->lastData.data());
 | 
	
		
			
				|  |  |  				// 假岱관;
 | 
	
		
			
				|  |  |  				pSocketContext->lastData.clear();
 | 
	
		
			
				|  |  | -				if (pIoContext->m_wsaBuf.len > lastlen)
 | 
	
		
			
				|  |  | -					pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + lastlen, pIoContext->m_wsaBuf.len - lastlen);
 | 
	
		
			
				|  |  | +				if (lastlen)
 | 
	
		
			
				|  |  | +					pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + pIoContext->m_Overlapped.InternalHigh - lastlen, lastlen);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			else
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  | -				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_wsaBuf.len);
 | 
	
		
			
				|  |  | +				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		else
 | 
	
		
			
				|  |  |  		{
 | 
	
		
			
				|  |  |  			int diflen = PAK_LEN - pSocketContext->lastData.size();
 | 
	
		
			
				|  |  | -			if ( diflen > pIoContext->m_wsaBuf.len )
 | 
	
		
			
				|  |  | +			if ( diflen > pIoContext->m_Overlapped.InternalHigh )
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  | -				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_wsaBuf.len);
 | 
	
		
			
				|  |  | +				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, pIoContext->m_Overlapped.InternalHigh);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			else
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  |  				pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf, diflen);
 | 
	
		
			
				|  |  |  				phead = (ProHeader*)pSocketContext->lastData.data();
 | 
	
		
			
				|  |  |  				// 供憐관;
 | 
	
		
			
				|  |  | -				if ( phead->len == PAK_LEN + pIoContext->m_wsaBuf.len - diflen )
 | 
	
		
			
				|  |  | +				if ( phead->len == PAK_LEN + pIoContext->m_Overlapped.InternalHigh - diflen )
 | 
	
		
			
				|  |  |  				{
 | 
	
		
			
				|  |  | -					_DeviceProc(pSocketContext, (Package*)pIoContext->m_wsaBuf.buf);
 | 
	
		
			
				|  |  | +					_DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  				// 鬼관;
 | 
	
		
			
				|  |  | -				else if ( phead->len > PAK_LEN + pIoContext->m_wsaBuf.len - diflen)
 | 
	
		
			
				|  |  | +				else if ( phead->len > PAK_LEN + pIoContext->m_Overlapped.InternalHigh - diflen)
 | 
	
		
			
				|  |  |  				{
 | 
	
		
			
				|  |  | -					pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + diflen, pIoContext->m_wsaBuf.len - diflen);
 | 
	
		
			
				|  |  | +					pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + diflen, pIoContext->m_Overlapped.InternalHigh - diflen);
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  				// 낚관;
 | 
	
		
			
				|  |  | -				else if (phead->len < PAK_LEN + pIoContext->m_wsaBuf.len - diflen)
 | 
	
		
			
				|  |  | +				else if (phead->len < PAK_LEN + pIoContext->m_Overlapped.InternalHigh - diflen)
 | 
	
		
			
				|  |  |  				{
 | 
	
		
			
				|  |  |  					// 莉供냥관;
 | 
	
		
			
				|  |  |  					pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + diflen, phead->len - PAK_LEN);
 | 
	
		
			
				|  |  | -					_DeviceProc(pSocketContext, (Package*)pIoContext->m_wsaBuf.buf);
 | 
	
		
			
				|  |  | +					_DeviceProc(pIoContext, (Package*)pIoContext->m_wsaBuf.buf);
 | 
	
		
			
				|  |  |  					pSocketContext->lastData.clear();
 | 
	
		
			
				|  |  | -					int last = pIoContext->m_wsaBuf.len - diflen - phead->len + PAK_LEN;
 | 
	
		
			
				|  |  | +					int last = pIoContext->m_Overlapped.InternalHigh - diflen - phead->len + PAK_LEN;
 | 
	
		
			
				|  |  |  					if (last)
 | 
	
		
			
				|  |  |  					{						
 | 
	
		
			
				|  |  | -						pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + pIoContext->m_wsaBuf.len - last, last);
 | 
	
		
			
				|  |  | +						pSocketContext->lastData.append(pIoContext->m_wsaBuf.buf + pIoContext->m_Overlapped.InternalHigh - last, last);
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  			}
 | 
	
	
		
			
				|  | @@ -854,14 +860,14 @@ void CIOCPModel::_RecvProcess(PER_SOCKET_CONTEXT* pSocketContext, PER_IO_CONTEXT
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void CIOCPModel::_DeviceProc(PER_SOCKET_CONTEXT* pSocketContext, Package* pak)
 | 
	
		
			
				|  |  | +void CIOCPModel::_DeviceProc(PER_IO_CONTEXT* pIoContext, Package* pak)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |  	if ( pak->header.version != 0xAA )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		return;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	cJSON* pJson = cJSON_Parse((const char*)pak->buf);
 | 
	
		
			
				|  |  | +	cJSON* pJson = cJSON_Parse((const char*)&pak->buf);
 | 
	
		
			
				|  |  |  	if ( pJson == NULL )
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		return;
 | 
	
	
		
			
				|  | @@ -885,8 +891,8 @@ void CIOCPModel::_DeviceProc(PER_SOCKET_CONTEXT* pSocketContext, Package* pak)
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// 蕨눔왯랙箇寧즈;
 | 
	
		
			
				|  |  | -	auto value = iter->second;
 | 
	
		
			
				|  |  | -	std::string readdata = value.SendCommond(reqj.device_cmd);
 | 
	
		
			
				|  |  | +	auto dev = iter->second;
 | 
	
		
			
				|  |  | +	std::string readdata = dev->SendCommond(reqj.device_cmd);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	ResponseJson repj;
 | 
	
		
			
				|  |  |  	repj.device_id = reqj.device_id;
 | 
	
	
		
			
				|  | @@ -896,10 +902,24 @@ void CIOCPModel::_DeviceProc(PER_SOCKET_CONTEXT* pSocketContext, Package* pak)
 | 
	
		
			
				|  |  |  	pJson = cJSON_CreateObject();
 | 
	
		
			
				|  |  |  	cJSON_AddNumberToObject(pJson, "device_id", repj.device_id);
 | 
	
		
			
				|  |  |  	cJSON_AddStringToObject(pJson, "device_name", repj.device_name.c_str());
 | 
	
		
			
				|  |  | -	cJSON_AddNumberToObject(pJson, "device_cmd_result", repj.device_cmd_result.c_str());
 | 
	
		
			
				|  |  | +	cJSON_AddStringToObject(pJson, "device_cmd_result", repj.device_cmd_result.c_str());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	char* pjdata = cJSON_Print(pJson);
 | 
	
		
			
				|  |  | -	send(pSocketContext->m_Socket, pjdata, strlen(pjdata), 0);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	Package reponse_pak;
 | 
	
		
			
				|  |  | +	reponse_pak.header.version = 0xAB;
 | 
	
		
			
				|  |  | +	reponse_pak.header.len = strlen(pjdata) + PAK_LEN;
 | 
	
		
			
				|  |  | +	reponse_pak.buf = new byte[strlen(pjdata)];
 | 
	
		
			
				|  |  | +	memcpy(reponse_pak.buf, pjdata, strlen(pjdata));
 | 
	
		
			
				|  |  | +	if ( pjdata)
 | 
	
		
			
				|  |  | +		free(pjdata);
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	int ret = send(pIoContext->m_sockAccept, (const char*)&reponse_pak, reponse_pak.header.len, 0);
 | 
	
		
			
				|  |  | +	delete[]reponse_pak.buf;
 | 
	
		
			
				|  |  | +	if ( ret == -1 )
 | 
	
		
			
				|  |  | +	{
 | 
	
		
			
				|  |  | +		DWORD dwEr = GetLastError();
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /////////////////////////////////////////////////////////////////////
 |