Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,50 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/RTTI/TypeInfo.h>
#include <AzCore/RTTI/TypeSafeIntegral.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
namespace AzNetworking
{
class ISerializer;
AZ_TYPE_SAFE_INTEGRAL(PacketType, uint16_t);
//! @class IPacket
//! @brief Base class for all packets.
class IPacket
{
public:
AZ_TYPE_INFO(IPacket, "{1B33BFE8-8A4B-44E3-8C8D-3B924093227C}");
virtual ~IPacket() = default;
//! Returns the packet type.
//! @return packet type
virtual PacketType GetPacketType() const = 0;
//! Returns an identical copy of the current packet instance, caller assumes ownership.
//! @return copy of the current packet instance, caller assumes ownership
virtual AZStd::unique_ptr<IPacket> Clone() const = 0;
//! Base serialize method for all serializable structures or classes to implement.
//! @param serializer ISerializer instance to use for serialization
//! @return boolean true for success, false for serialization failure
virtual bool Serialize(ISerializer& serializer) = 0;
};
}
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(AzNetworking::PacketType);
@@ -0,0 +1,54 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Preprocessor/Enum.h>
#include <AzNetworking/PacketLayer/IPacket.h>
#include <AzNetworking/DataStructures/FixedSizeBitset.h>
#include <AzNetworking/ConnectionLayer/ConnectionMetrics.h>
namespace AzNetworking
{
AZ_ENUM_CLASS(PacketFlag
, Compressed
, MAX
);
using PacketFlagBitset = FixedSizeBitset<1, uint8_t>;
static_assert(aznumeric_cast<int>(PacketFlag::MAX) <= 8, "PacketFlags are limited to 1 byte (8 flags)");
//! @class IPacketHeader
//! @brief A packet header that lets us deduce packet type for any incoming packet.
class IPacketHeader
{
public:
AZ_TYPE_INFO(IPacketHeader, "{90A0EFE3-01A4-4F04-87CF-E98E94D49648}");
virtual ~IPacketHeader() = default;
//! Returns the packet type.
//! @return packet type
virtual PacketType GetPacketType() const = 0;
//! Returns the packet id.
//! @return PacketId
virtual PacketId GetPacketId() const = 0;
//! Returns if the specified packet flag is set for this packet.
//! @return true if the flag is set for this packet
virtual bool IsPacketFlagSet(PacketFlag flag) const = 0;
//! Sets the specified packet flag for this packet.
virtual void SetPacketFlag(PacketFlag flag, bool value) = 0;
};
}