mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-01-03 16:13:34 +08:00
[raknet] Add TCPInterface class
* Adds TCPInterface ctor * Adds `TCPInterface::Receive()` * Adds `TCPInterface::HasLostConnection()`
This commit is contained in:
parent
df9176c717
commit
270ee9a0bc
@ -13,11 +13,30 @@ typedef unsigned int RakNetTime;
|
||||
typedef long long RakNetTimeNS;
|
||||
#endif
|
||||
|
||||
/// \brief Unique identifier for a system.
|
||||
/// Corresponds to a network address
|
||||
struct RAK_DLL_EXPORT PlayerID
|
||||
{
|
||||
char _gap0[6];
|
||||
};
|
||||
|
||||
/// This represents a user message from another system.
|
||||
struct Packet
|
||||
{
|
||||
char _gap0;
|
||||
};
|
||||
|
||||
struct RPCParameters
|
||||
{
|
||||
char _gap0; // TODO: RPCParameters
|
||||
};
|
||||
|
||||
/// Index of an invalid PlayerID
|
||||
const PlayerID UNASSIGNED_PLAYER_ID =
|
||||
{
|
||||
0xFFFFFFFF, 0xFFFF
|
||||
};
|
||||
|
||||
/// \def REGISTER_STATIC_RPC
|
||||
/// \ingroup RAKNET_RPC
|
||||
/// Register a C function as a Remote procedure.
|
||||
|
28
raknet/TCPInterface.cpp
Normal file
28
raknet/TCPInterface.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// TODO: Implement TCPInterface.cpp
|
||||
|
||||
#include "TCPInterface.h"
|
||||
|
||||
TCPInterface::TCPInterface()
|
||||
{
|
||||
}
|
||||
|
||||
Packet* TCPInterface::Receive( void )
|
||||
{
|
||||
if (isStarted==false)
|
||||
return 0;
|
||||
return incomingMessages.ReadLock();
|
||||
}
|
||||
PlayerID TCPInterface::HasLostConnection(void)
|
||||
{
|
||||
PlayerID *out;
|
||||
out = lostConnections.ReadLock();
|
||||
if (out)
|
||||
{
|
||||
lostConnections.ReadUnlock();
|
||||
return *out;
|
||||
}
|
||||
else
|
||||
{
|
||||
return UNASSIGNED_PLAYER_ID;
|
||||
}
|
||||
}
|
31
raknet/TCPInterface.h
Normal file
31
raknet/TCPInterface.h
Normal file
@ -0,0 +1,31 @@
|
||||
// TODO: Implement TCPInterface.h
|
||||
|
||||
#ifndef __SIMPLE_TCP_SERVER
|
||||
#define __SIMPLE_TCP_SERVER
|
||||
|
||||
#include "NetworkTypes.h"
|
||||
#include "SingleProducerConsumer.h"
|
||||
#include "Export.h"
|
||||
|
||||
/// \internal
|
||||
/// \brief As the name says, a simple multithreaded TCP server. Used by TelnetTransport
|
||||
class RAK_DLL_EXPORT TCPInterface
|
||||
{
|
||||
public:
|
||||
TCPInterface();
|
||||
|
||||
/// Returns data received
|
||||
Packet* Receive( void );
|
||||
|
||||
/// Queued events of lost connections
|
||||
PlayerID HasLostConnection(void);
|
||||
|
||||
protected:
|
||||
bool isStarted;
|
||||
|
||||
DataStructures::SingleProducerConsumer<Packet> incomingMessages;
|
||||
|
||||
DataStructures::SingleProducerConsumer<PlayerID> lostConnections;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user