mirror of
https://github.com/dashr9230/SA-MP.git
synced 2024-12-22 22:47:29 +08:00
[raknet] Implement EmailSender::GetResponse()
This commit is contained in:
parent
270ee9a0bc
commit
2e7a8b8bda
38
raknet/EmailSender.cpp
Normal file
38
raknet/EmailSender.cpp
Normal 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
16
raknet/EmailSender.h
Normal 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
|
@ -1 +1,8 @@
|
||||
// TODO: Implement NetworkTypes.cpp
|
||||
// TODO: Implement NetworkTypes.cpp
|
||||
|
||||
#include "NetworkTypes.h"
|
||||
|
||||
bool PlayerID::operator==( const PlayerID& right ) const
|
||||
{
|
||||
return binaryAddress == right.binaryAddress && port == right.port;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user