Add NetworkBase.
This commit is contained in:
63
Source/Engine/Platform/Base/NetworkBase.cpp
Normal file
63
Source/Engine/Platform/Base/NetworkBase.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "NetworkBase.h"
|
||||
|
||||
bool NetworkBase::Init()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void NetworkBase::Exit()
|
||||
{
|
||||
}
|
||||
|
||||
bool NetworkBase::CreateSocket(NetworkSocket& socket, NetworkSocketCreateSettings& settings)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkBase::DestroySocket(NetworkSocket& socket)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkBase::ConnectSocket(NetworkSocket& socket, NetworkEndPoint& endPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkBase::BindSocket(NetworkSocket& socket, NetworkEndPoint& endPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkBase::Accept(NetworkSocket& serverSock, NetworkSocket& newSock, NetworkEndPoint& newEndPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkBase::IsReadable(NetworkSocket& socket, uint64* size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 NetworkBase::WriteSocket(NetworkSocket socket, byte* data, uint32 length, NetworkEndPoint* endPoint)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 NetworkBase::ReadSocket(NetworkSocket socket, byte* buffer, uint32 bufferSize, NetworkEndPoint* endPoint)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool NetworkBase::CreateEndPoint(String* address, String* port, NetworkIPVersion ipv, NetworkEndPoint& endPoint)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkEndPoint NetworkBase::RemapEndPointToIPv6(NetworkEndPoint& endPoint)
|
||||
{
|
||||
return NetworkEndPoint();
|
||||
}
|
||||
|
||||
63
Source/Engine/Platform/Base/NetworkBase.h
Normal file
63
Source/Engine/Platform/Base/NetworkBase.h
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Core/Types/BaseTypes.h"
|
||||
#include "Engine/Core/Types/String.h"
|
||||
API_INJECT_CPP_CODE("#include \"Engine/Platform/Network.h\"");
|
||||
|
||||
enum class FLAXENGINE_API NetworkProtocolType
|
||||
{
|
||||
Undefined,
|
||||
Udp,
|
||||
Tcp
|
||||
};
|
||||
|
||||
enum class FLAXENGINE_API NetworkIPVersion
|
||||
{
|
||||
Undefined,
|
||||
IPv4,
|
||||
IPv6
|
||||
};
|
||||
|
||||
struct FLAXENGINE_API NetworkSocketCreateSettings
|
||||
{
|
||||
NetworkProtocolType Protocol = NetworkProtocolType::Udp;
|
||||
NetworkIPVersion IPVersion = NetworkIPVersion::IPv4;
|
||||
bool DualStacking = true;
|
||||
bool ReuseAddress = true;
|
||||
bool Broadcast = false;
|
||||
};
|
||||
|
||||
struct FLAXENGINE_API NetworkSocket
|
||||
{
|
||||
NetworkProtocolType Protocol = NetworkProtocolType::Undefined;
|
||||
NetworkIPVersion IPVersion = NetworkIPVersion::Undefined;
|
||||
byte Data[8] = {}; // sizeof SOCKET = unsigned __int64
|
||||
};
|
||||
|
||||
struct FLAXENGINE_API NetworkEndPoint
|
||||
{
|
||||
NetworkIPVersion IPVersion = NetworkIPVersion::Undefined;
|
||||
String Address;
|
||||
String Port;
|
||||
byte Data[28] = {}; // sizeof sockaddr_in6 , biggest sockaddr that we will use
|
||||
};
|
||||
|
||||
class FLAXENGINE_API NetworkBase
|
||||
{
|
||||
public:
|
||||
static bool Init();
|
||||
static void Exit();
|
||||
static bool CreateSocket(NetworkSocket& socket, NetworkSocketCreateSettings& settings);
|
||||
static bool DestroySocket(NetworkSocket& socket);
|
||||
static bool ConnectSocket(NetworkSocket& socket, NetworkEndPoint& endPoint);
|
||||
static bool BindSocket(NetworkSocket& socket, NetworkEndPoint& endPoint);
|
||||
static bool Accept(NetworkSocket& serverSock, NetworkSocket& newSock, NetworkEndPoint& newEndPoint);
|
||||
static bool IsReadable(NetworkSocket& socket, uint64* size);
|
||||
static uint32 WriteSocket(NetworkSocket socket, byte* data, uint32 length, NetworkEndPoint* endPoint = nullptr);
|
||||
static uint32 ReadSocket(NetworkSocket socket, byte* buffer, uint32 bufferSize, NetworkEndPoint* endPoint = nullptr);
|
||||
static bool CreateEndPoint(String* address, String* port, NetworkIPVersion ipv, NetworkEndPoint& endPoint);
|
||||
static NetworkEndPoint RemapEndPointToIPv6(NetworkEndPoint& endPoint);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user