// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "NetworkConnection.h" #include "NetworkMessage.h" #include "Engine/Scripting/ScriptingType.h" /// /// Network event type enum contains all possible events that can be returned by PopEvent function. /// API_ENUM(Namespace="FlaxEngine.Networking") enum class NetworkEventType { /// /// Invalid network event type. /// Undefined = 0, /// /// Event "connected" - client connected to our server or we've connected to the server. /// Connected, /// /// Event "disconnected" - client disconnected from our server or we've been kicked from the server. /// Disconnected, /// /// Event "disconnected" - client got a timeout from our server or we've list the connection to the server. /// Timeout, /// /// Event "message" - message received from some client or the server. /// Message }; /// /// Network event structure that wraps all data needed to identify and process it. /// API_STRUCT(Namespace="FlaxEngine.Networking") struct FLAXENGINE_API NetworkEvent { DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkEvent); public: /// /// The type of the received event. /// API_FIELD(); NetworkEventType EventType; /// /// The message when this event is an "message" event - not valid in any other cases. /// If this is an message-event, make sure to return the message using RecycleMessage function of the peer after processing it! /// API_FIELD(); NetworkMessage Message; /// /// The connected of the client that has sent message, connected, disconnected or got a timeout. /// /// Only valid when event has been received on server-peer. API_FIELD(); NetworkConnection Sender; };