コード例 #1
0
ファイル: GameClient.cs プロジェクト: asmCode/soccer_game
    public void SendReadyToStart()
    {
        var msg = new ReadyToStart();

        m_netMsgSerializer.Serialize(msg);
        m_com.Send(m_netMsgSerializer.Data, m_netMsgSerializer.DataSize, m_serverAddress);
    }
コード例 #2
0
ファイル: FakeClient.cs プロジェクト: asmCode/soccer_game
    public void SendReadyToStart()
    {
        var msg = new ReadyToStart();

        m_netMsgSerializer.Serialize(msg);

        OutMessages.Enqueue(new RawData(m_netMsgSerializer.Data, m_netMsgSerializer.DataSize));
    }
コード例 #3
0
    private void ProcessReadyToStart(GameServer gameServer, ReadyToStart msg, INetworkAddress address)
    {
        Debug.LogFormat("ReadyToStart, Address: {0}", address.ToString());

        var clientInfo = gameServer.GetClientInfoByAddress(address);

        if (clientInfo != null && clientInfo.IsReadyToStart)
        {
            return;
        }

        gameServer.SetReadyToStart(address);
    }
コード例 #4
0
        /// <summary>
        /// Attempts to start playback. Waits for all player clocks to have available frames for up to <see cref="MAXIMUM_START_DELAY"/> milliseconds.
        /// </summary>
        /// <returns>Whether playback was started and syncing should occur.</returns>
        private bool attemptStart()
        {
            if (hasStarted)
            {
                return(true);
            }

            if (playerClocks.Count == 0)
            {
                return(false);
            }

            int readyCount = playerClocks.Count(s => !s.WaitingOnFrames.Value);

            if (readyCount == playerClocks.Count)
            {
                return(performStart());
            }

            if (readyCount > 0)
            {
                firstStartAttemptTime ??= Time.Current;

                if (Time.Current - firstStartAttemptTime > MAXIMUM_START_DELAY)
                {
                    return(performStart());
                }
            }

            bool performStart()
            {
                ReadyToStart?.Invoke();
                return(hasStarted = true);
            }

            return(false);
        }
コード例 #5
0
 public void Serialize(ReadyToStart message)
 {
     m_writer.Reset();
     m_writer.Write(NetworkMessageType.ReadyToStart);
     m_writer.Flush();
 }