[raknet] Implement EmailSender::GetResponse()

This commit is contained in:
RD42 2024-02-13 23:27:04 +08:00
parent 270ee9a0bc
commit 2e7a8b8bda
4 changed files with 70 additions and 3 deletions

38
raknet/EmailSender.cpp Normal file
View File

@ -0,0 +1,38 @@
// TODO: Implement EmailSender.cpp
#include "EmailSender.h"
#include "TCPInterface.h"
#include "GetTime.h"
#include <stdio.h>
#include <string.h> // strstr
#include "RakSleep.h"
char *EmailSender::GetResponse(TCPInterface *tcpInterface, const PlayerID &emailServer, bool doPrintf)
{
Packet *packet;
RakNetTime timeout;
timeout=RakNet::GetTime()+5000;
while (1)
{
if (tcpInterface->HasLostConnection()==emailServer)
return "Connection to server lost.";
packet = tcpInterface->Receive();
if (packet)
{
if (doPrintf)
printf("%s", packet->data);
if (strstr((const char*)packet->data, "250"))
return 0; // OK
if (strstr((const char*)packet->data, "354"))
return 0; // OK
if (strstr((const char*)packet->data, "550"))
return "Failed on error code 550";
if (strstr((const char*)packet->data, "553"))
return "Failed on error code 553";
}
if (RakNet::GetTime() > timeout)
return "Timed out";
RakSleep(100);
}
}

16
raknet/EmailSender.h Normal file
View File

@ -0,0 +1,16 @@
// TODO: Implement EmailSender.h
#ifndef __EMAIL_SENDER_H
#define __EMAIL_SENDER_H
class TCPInterface;
#include "NetworkTypes.h"
class EmailSender
{
public:
protected:
char *GetResponse(TCPInterface *tcpInterface, const PlayerID &emailServer, bool doPrintf);
};
#endif

View File

@ -1 +1,8 @@
// TODO: Implement NetworkTypes.cpp
#include "NetworkTypes.h"
bool PlayerID::operator==( const PlayerID& right ) const
{
return binaryAddress == right.binaryAddress && port == right.port;
}

View File

@ -17,13 +17,19 @@ typedef long long RakNetTimeNS;
/// Corresponds to a network address
struct RAK_DLL_EXPORT PlayerID
{
char _gap0[6];
///The peer address from inet_addr.
unsigned int binaryAddress;
///The port number
unsigned short port;
bool operator==( const PlayerID& right ) const;
};
/// This represents a user message from another system.
struct Packet
{
char _gap0;
/// The data from the sender
unsigned char* data;
};
struct RPCParameters