Beispiel #1
0
        private void UpdateJoinable(bool startingGame = false)
        {
            if (!NetGame.isServer)
            {
                return;
            }
            NetTransport transport = NetGame.instance.transport;

            if (NetGame.instance.players.Count < Options.lobbyMaxPlayers)
            {
                UnityEngine.Debug.Log("UpdateJoinable : hasSlots");
                if (state == AppSate.ServerLobby && !startingGame)
                {
                    UnityEngine.Debug.Log("UpdateJoinable : in lobby");
                    transport.SetJoinable(joinable: true, haveStarted: false);
                }
                else
                {
                    UnityEngine.Debug.Log("UpdateJoinable : join in progress = " + Options.lobbyJoinInProgress.ToString());
                    transport.SetJoinable(Options.lobbyJoinInProgress != 0, haveStarted: true);
                }
            }
            else
            {
                UnityEngine.Debug.Log("UpdateJoinable : noSlots");
                transport.SetJoinable(joinable: false, state != AppSate.ServerLobby || startingGame);
            }
        }
Beispiel #2
0
 public void FlushBuffer(NetTransport transport, bool skipLock = false)
 {
     lock (unreliableStreamLock)
     {
         if (unreliableStream.position != 0)
         {
             unreliableStream.WriteStream(null);
             transport.SendUnreliable(this, unreliableStream.GetOriginalBuffer(), unreliableStream.UseBuffedSize());
             NetGame.instance.sendBps.ReportBits(unreliableStream.position);
             unreliableStream.Seek(0);
         }
     }
 }
Beispiel #3
0
 public void Buffer(NetStream stream, NetTransport transport, int expectedContainerId)
 {
     lock (unreliableStreamLock)
     {
         if (!CanBuffer(stream, expectedContainerId))
         {
             FlushBuffer(transport);
         }
         if (unreliableStream.position == 0)
         {
             unreliableStream.WriteMsgId(NetMsgId.Container);
             unreliableStream.Write(NetGame.currentLevelInstanceID, 4);
             currentBufferTag = NetGame.currentLevelInstanceID;
             unreliableStream.Write((uint)writeFrameId, 22);
         }
         unreliableStream.WriteStream(stream);
     }
 }