SetMaxDelay() public method

The maximum time in seconds that messages are buffered before being sent.

public SetMaxDelay ( float seconds ) : void
seconds float Time in seconds.
return void
コード例 #1
0
 public void SetMaxDelay(float seconds)
 {
     if (m_Connection == null)
     {
         if (LogFilter.logWarn)
         {
             Debug.LogWarning("SetMaxDelay failed, not connected.");
         }
     }
     else
     {
         m_Connection.SetMaxDelay(seconds);
     }
 }
コード例 #2
0
 internal void InternalUpdate()
 {
     if (this.m_ServerId == -1 || !NetworkTransport.IsStarted)
     return;
       int num = 0;
       byte error1;
       if (this.m_RelaySlotId != -1)
       {
     NetworkEventType networkEventType = NetworkTransport.ReceiveRelayEventFromHost(this.m_ServerId, out error1);
     if (networkEventType != NetworkEventType.Nothing && LogFilter.logDebug)
       Debug.Log((object) ("NetGroup event:" + (object) networkEventType));
     if (networkEventType == NetworkEventType.ConnectEvent && LogFilter.logDebug)
       Debug.Log((object) "NetGroup server connected");
     if (networkEventType == NetworkEventType.DisconnectEvent && LogFilter.logDebug)
       Debug.Log((object) "NetGroup server disconnected");
       }
       NetworkEventType networkEventType1;
       do
       {
     int connectionId;
     int channelId;
     int receivedSize;
     networkEventType1 = NetworkTransport.ReceiveFromHost(this.m_ServerId, out connectionId, out channelId, this.m_MsgBuffer, (int) (ushort) this.m_MsgBuffer.Length, out receivedSize, out error1);
     if (networkEventType1 != NetworkEventType.Nothing && LogFilter.logDev)
     {
       object[] objArray = new object[6];
       int index1 = 0;
       string str1 = "Server event: host=";
       objArray[index1] = (object) str1;
       int index2 = 1;
       // ISSUE: variable of a boxed type
       __Boxed<int> local1 = (ValueType) this.m_ServerId;
       objArray[index2] = (object) local1;
       int index3 = 2;
       string str2 = " event=";
       objArray[index3] = (object) str2;
       int index4 = 3;
       // ISSUE: variable of a boxed type
       __Boxed<NetworkEventType> local2 = (Enum) networkEventType1;
       objArray[index4] = (object) local2;
       int index5 = 4;
       string str3 = " error=";
       objArray[index5] = (object) str3;
       int index6 = 5;
       // ISSUE: variable of a boxed type
       __Boxed<byte> local3 = (ValueType) error1;
       objArray[index6] = (object) local3;
       Debug.Log((object) string.Concat(objArray));
     }
     switch (networkEventType1)
     {
       case NetworkEventType.DataEvent:
     NetworkConnection conn = this.m_Connections.Get(connectionId);
     if ((int) error1 != 0)
     {
       this.GenerateDataError(conn, (int) error1);
       return;
     }
     NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, (short) 29, "msg", 1);
     if (conn != null)
     {
       this.m_MsgReader.SeekZero();
       conn.HandleMessage(this.m_MessageHandlers.GetHandlers(), this.m_MsgReader, receivedSize, channelId);
       goto case 3;
     }
     else if (LogFilter.logError)
     {
       Debug.LogError((object) "Unknown connection data event?!?");
       goto case 3;
     }
     else
       goto case 3;
       case NetworkEventType.ConnectEvent:
     if (LogFilter.logDebug)
       Debug.Log((object) ("Server accepted client:" + (object) connectionId));
     if ((int) error1 != 0)
     {
       this.GenerateConnectError((int) error1);
       return;
     }
     string address;
     int port;
     NetworkID network;
     NodeID dstNode;
     byte error2;
     NetworkTransport.GetConnectionInfo(this.m_ServerId, connectionId, out address, out port, out network, out dstNode, out error2);
     NetworkConnection networkConnection = new NetworkConnection();
     networkConnection.Initialize(address, this.m_ServerId, connectionId, this.m_hostTopology);
     networkConnection.SetMaxDelay(this.m_MaxDelay);
     this.m_Connections.Add(connectionId, networkConnection);
     this.m_MessageHandlers.InvokeHandlerNoData((short) 32, networkConnection);
     if (this.m_SendPeerInfo)
       this.SendNetworkInfo(networkConnection);
     this.SendCRC(networkConnection);
     goto case 3;
       case NetworkEventType.DisconnectEvent:
     NetworkConnection @unsafe = this.m_Connections.GetUnsafe(connectionId);
     if ((int) error1 != 0 && (int) error1 != 6)
       this.GenerateDisconnectError(@unsafe, (int) error1);
     this.m_Connections.Remove(connectionId);
     if (@unsafe != null)
     {
       this.m_MessageHandlers.InvokeHandlerNoData((short) 33, @unsafe);
       for (int index = 0; index < @unsafe.playerControllers.Count; ++index)
       {
         if ((UnityEngine.Object) @unsafe.playerControllers[index].gameObject != (UnityEngine.Object) null && LogFilter.logWarn)
           Debug.LogWarning((object) "Player not destroyed when connection disconnected.");
       }
       if (LogFilter.logDebug)
         Debug.Log((object) ("Server lost client:" + (object) connectionId));
       @unsafe.RemoveObservers();
       @unsafe.Dispose();
     }
     else if (LogFilter.logDebug)
       Debug.Log((object) "Connection is null in disconnect event");
     if (this.m_SendPeerInfo)
     {
       this.SendNetworkInfo(@unsafe);
       goto case 3;
     }
     else
       goto case 3;
       case NetworkEventType.Nothing:
     if (++num >= 500)
     {
       if (LogFilter.logDebug)
       {
         Debug.Log((object) ("kMaxEventsPerFrame hit (" + (object) 500 + ")"));
         goto label_47;
       }
       else
         goto label_47;
     }
     else
       continue;
       default:
     if (LogFilter.logError)
     {
       Debug.LogError((object) ("Unknown network message type received: " + (object) networkEventType1));
       goto case 3;
     }
     else
       goto case 3;
     }
       }
       while (networkEventType1 != NetworkEventType.Nothing);
     label_47:
       this.UpdateServerObjects();
       for (int localIndex = this.m_Connections.LocalIndex; localIndex < this.m_Connections.Count; ++localIndex)
       {
     NetworkConnection networkConnection = this.m_Connections.Get(localIndex);
     if (networkConnection != null)
       networkConnection.FlushInternalBuffer();
       }
 }
コード例 #3
0
 private void OnConnected(NetworkConnection conn)
 {
     if (LogFilter.logDebug)
     {
         Debug.Log("Server accepted client:" + conn.connectionId);
     }
     conn.SetMaxDelay(this.m_MaxDelay);
     conn.InvokeHandlerNoData(0x20);
     SendCrc(conn);
 }