void ZBirdDummyClient::SendCommand(MCommand* pCommand)
{
	static unsigned char nSerial = 0;
	nSerial++;
	pCommand->m_nSerialNumber = nSerial;


	int nPacketSize = CalcPacketSize(pCommand);
	char* pSendBuf = new char[nPacketSize];

	int size = MakeCmdPacket(pSendBuf, nPacketSize, pCommand);

	m_ClientSocket.Send(pSendBuf, size);		
}
Exemple #2
0
bool MMatchClient::SendCommandToAgent(MCommand* pCommand)
{
	int nPacketSize = CalcPacketSize(pCommand);
	char* pSendBuf = new char[nPacketSize];

	int size = MakeCmdPacket(pSendBuf, nPacketSize, &m_AgentPacketCrypter, pCommand);

	if (size > 0)
	{
		return m_AgentSocket.Send(pSendBuf, size);
	}
	else
	{
		delete [] pSendBuf;
		return false;
	}
}
Exemple #3
0
void MMatchClient::SendCommandByUDP(MCommand* pCommand, char* szIP, int nPort)
{
	int nPacketSize = CalcPacketSize(pCommand);
	char* pSendBuf = new char[nPacketSize];

	// ##중요## - MMatchServer, MMatchAgent와 UDP통신할 때에는 암호화하지 않는 Command만 전송이 가능하다. 
	int nSize = MakeCmdPacket(pSendBuf, nPacketSize, &m_PeerPacketCrypter, pCommand);


	_ASSERT(nPacketSize > 0 && nPacketSize == nSize);

	if (nSize > 0)
	{
		m_SafeUDP.Send(szIP, nPort, pSendBuf, nSize);
	}
	else
	{
		_ASSERT(0);
		delete [] pSendBuf;
	}
}
Exemple #4
0
bool TcpSocket::ParseTcpHeader(const char* data, int size, int& dealed_size) {
  if (current_header_.size() < kTcpHeaderSize) {
    int left_header_size = kTcpHeaderSize - current_header_.size();
    if (left_header_size > size) {
      for (auto i = 0; i < size; ++i) {
        current_header_.push_back(data[i]);
      }
      dealed_size = size;
    } else {
      for (auto i = 0; i < left_header_size; ++i) {
        current_header_.push_back(data[i]);
      }
      dealed_size = left_header_size;
      current_packet_.clear();
      if (!CalcPacketSize()) {
        return false;
      }
      current_packet_.reserve(current_packet_size_);
    }
  }
  return true;
}