/// <summary>
        /// Logs the start of a new game session for a local player.
        ///
        /// The game client should call this function whenever it joins into a new multiplayer, peer-to-peer or single player game session.
        /// Each call to BeginPlayerSession must be matched with a corresponding call to EndPlayerSession.
        /// </summary>
        /// <param name="options">Structure containing the local player's game account and the game session information.</param>
        /// <returns>
        /// Returns <see cref="Result.Success" /> on success, or an error code if the input parameters are invalid or an active session for the player already exists.
        /// </returns>
        public Result BeginPlayerSession(BeginPlayerSessionOptions options)
        {
            System.IntPtr optionsAddress = new System.IntPtr();
            Helper.TryMarshalSet <BeginPlayerSessionOptionsInternal, BeginPlayerSessionOptions>(ref optionsAddress, options);

            var funcResult = EOS_Metrics_BeginPlayerSession(InnerHandle, optionsAddress);

            Helper.TryMarshalDispose(ref optionsAddress);

            return(funcResult);
        }
Exemplo n.º 2
0
 public void Set(BeginPlayerSessionOptions other)
 {
     if (other != null)
     {
         m_ApiVersion   = MetricsInterface.BeginplayersessionApiLatest;
         AccountId      = other.AccountId;
         DisplayName    = other.DisplayName;
         ControllerType = other.ControllerType;
         ServerIp       = other.ServerIp;
         GameSessionId  = other.GameSessionId;
     }
 }
Exemplo n.º 3
0
        public override void ClientConnect(string address)
        {
            if (!EOSSDKComponent.Initialized)
            {
                Debug.LogError("EOS not initialized. Client could not be started.");
                OnClientDisconnected.Invoke();
                return;
            }

            StartCoroutine("FetchEpicAccountId");

            if (ServerActive())
            {
                Debug.LogError("Transport already running as server!");
                return;
            }

            if (!ClientActive() || client.Error)
            {
                Debug.Log($"Starting client, target address {address}.");

                //client = Client.CreateClient(this, address);
                activeNode = client;

                if (EOSSDKComponent.CollectPlayerMetrics)
                {
                    // Start Metrics colletion session
                    BeginPlayerSessionOptions sessionOptions = new BeginPlayerSessionOptions();
                    sessionOptions.AccountId      = EOSSDKComponent.LocalUserAccountId;
                    sessionOptions.ControllerType = UserControllerType.Unknown;
                    sessionOptions.DisplayName    = EOSSDKComponent.DisplayName;
                    sessionOptions.GameSessionId  = null;
                    sessionOptions.ServerIp       = null;
                    Result result = EOSSDKComponent.GetMetricsInterface().BeginPlayerSession(sessionOptions);

                    if (result == Result.Success)
                    {
                        Debug.Log("Started Metric Session");
                    }
                }
            }
            else
            {
                Debug.LogError("Client already running!");
            }
        }
Exemplo n.º 4
0
        public override void ServerStart()
        {
            if (!EOSSDKComponent.Initialized)
            {
                Debug.LogError("EOS not initialized. Server could not be started.");
                return;
            }

            StartCoroutine("FetchEpicAccountId");

            if (ClientActive())
            {
                Debug.LogError("Transport already running as client!");
                return;
            }

            if (!ServerActive())
            {
                Debug.Log("Starting server.");

                //server = Server.CreateServer(this, maxConnections);
                activeNode = server;

                if (EOSSDKComponent.CollectPlayerMetrics)
                {
                    // Start Metrics colletion session
                    BeginPlayerSessionOptions sessionOptions = new BeginPlayerSessionOptions();
                    sessionOptions.AccountId      = EOSSDKComponent.LocalUserAccountId;
                    sessionOptions.ControllerType = UserControllerType.Unknown;
                    sessionOptions.DisplayName    = EOSSDKComponent.DisplayName;
                    sessionOptions.GameSessionId  = null;
                    sessionOptions.ServerIp       = null;
                    Result result = EOSSDKComponent.GetMetricsInterface().BeginPlayerSession(sessionOptions);

                    if (result == Result.Success)
                    {
                        Debug.Log("Started Metric Session");
                    }
                }
            }
            else
            {
                Debug.LogError("Server already started!");
            }
        }
Exemplo n.º 5
0
        public override void ServerStart()
        {
            if (ClientActive())
            {
                Debug.LogError("Transport already running as client!");
                return;
            }

            if (!ServerActive())
            {
                Debug.Log("Starting server.");

                server     = Server.CreateServer(this, NetworkManager.singleton.maxConnections);
                activeNode = server;

                if (CollectPlayerMetrics)
                {
                    // Start Metrics colletion session
                    BeginPlayerSessionOptions sessionOptions = new BeginPlayerSessionOptions();
                    // sessionOptions.AccountId = EOSSDKComponent.LocalUserAccountId;
                    sessionOptions.AccountId = new BeginPlayerSessionOptionsAccountId()
                    {
                        External = LocalUserProductIdString
                    };
                    sessionOptions.ControllerType = UserControllerType.Unknown;
                    sessionOptions.DisplayName    = DisplayName;
                    sessionOptions.GameSessionId  = null;
                    sessionOptions.ServerIp       = null;
                    Result result = MetricsInterface.BeginPlayerSession(sessionOptions);

                    if (result == Result.Success)
                    {
                        Debug.Log("Started Metric Session");
                    }
                }
            }
            else
            {
                Debug.LogError("Server already started!");
            }
        }
Exemplo n.º 6
0
        public override void ClientConnect(string address)
        {
            if (ServerActive())
            {
                Debug.LogError("Transport already running as server!");
                return;
            }

            if (!ClientActive() || client.Error)
            {
                Debug.Log($"Starting client, target address {address}.");

                client     = Client.CreateClient(this, address);
                activeNode = client;

                if (CollectPlayerMetrics)
                {
                    // Start Metrics collection session
                    BeginPlayerSessionOptions sessionOptions = new BeginPlayerSessionOptions();
                    // sessionOptions.AccountId = EosTransport.LocalUserProductId;
                    sessionOptions.AccountId = new BeginPlayerSessionOptionsAccountId()
                    {
                        External = LocalUserProductIdString
                    };
                    sessionOptions.ControllerType = UserControllerType.Unknown;
                    sessionOptions.DisplayName    = DisplayName;
                    sessionOptions.GameSessionId  = null;
                    sessionOptions.ServerIp       = null;
                    Result result = MetricsInterface.BeginPlayerSession(sessionOptions);

                    if (result == Result.Success)
                    {
                        Debug.Log("Started Metric Session");
                    }
                }
            }
            else
            {
                Debug.LogError("Client already running!");
            }
        }