internal Connection(ulong id, ConnectionState state, IPEndPoint endpoint, RuffleSocket socket) { #if ALLOW_CONNECTION_STUB if (IsStub) { // NOOP return; } #endif this.Id = id; this.Socket = socket; this.EndPoint = endpoint; this.MTU = Config.MinimumMTU; this.SmoothRoundtrip = 0; this.HighestRoundtripVarience = 0; this.Roundtrip = 500; this.LowestRoundtrip = 500; this.LastMessageIn = NetTime.Now; this.LastMessageOut = NetTime.Now; this.ConnectionStarted = NetTime.Now; this.ConnectionCompleted = NetTime.Now; this.HandshakeStarted = NetTime.Now; this.HandshakeLastSendTime = NetTime.Now; this.HandshakeResendAttempts = 0; this.ChallengeAnswer = 0; this.ConnectionChallenge = RandomProvider.GetRandomULong(); this.ChallengeDifficulty = (byte)Config.ChallengeDifficulty; this.PreConnectionChallengeTimestamp = 0; this.PreConnectionChallengeCounter = 0; this.PreConnectionChallengeIV = 0; this.PreConnectionChallengeSolved = false; this.State = state; if (Config.EnableBandwidthTracking && Config.CreateBandwidthTracker != null) { this.BandwidthTracker = Config.CreateBandwidthTracker(); } if (Config.EnableHeartbeats) { this.HeartbeatChannel = new UnreliableOrderedChannel(0, this, Config, MemoryManager); } if (Config.EnablePacketMerging) { this.Merger = new MessageMerger(Config.MaxMergeMessageSize, Config.MinimumMTU); } if (Logging.CurrentLogLevel <= LogLevel.Debug) { Logging.LogInfo("Allocating " + Config.EventQueueSize + " event slots"); } this._userEventQueue = new ConcurrentCircularQueue <NetworkEvent>(Config.EventQueueSize, true); this.IsUserEventQueueActive = true; }
internal Connection(ulong id, ConnectionState state, IPEndPoint endpoint, RuffleSocket socket) { #if ALLOW_CONNECTION_STUB if (IsStub) { // NOOP return; } #endif this.Id = id; this.Socket = socket; this.EndPoint = endpoint; this.MTU = Config.MinimumMTU; this.SmoothRoundtrip = 0; this.HighestRoundtripVarience = 0; this.Roundtrip = 500; this.LowestRoundtrip = 500; this.LastMessageIn = NetTime.Now; this.LastMessageOut = NetTime.Now; this.ConnectionStarted = NetTime.Now; this.ConnectionCompleted = NetTime.Now; this.HandshakeStarted = NetTime.Now; this.HandshakeLastSendTime = NetTime.Now; this.HandshakeResendAttempts = 0; this.ChallengeAnswer = 0; this.ConnectionChallenge = RandomProvider.GetRandomULong(); this.ChallengeDifficulty = (byte)Config.ChallengeDifficulty; this.PreConnectionChallengeTimestamp = 0; this.PreConnectionChallengeCounter = 0; this.PreConnectionChallengeIV = 0; this.PreConnectionChallengeSolved = false; this.State = state; if (Config.EnableBandwidthTracking && Config.CreateBandwidthTracker != null) { this.BandwidthTracker = Config.CreateBandwidthTracker(); } if (Config.EnableHeartbeats) { this.HeartbeatChannel = new UnreliableOrderedChannel(0, this, Config, MemoryManager); } if (Config.EnablePacketMerging) { this.Merger = new MessageMerger(Config.MaxMergeMessageSize, Config.MinimumMTU, Config.MaxMergeDelay); } }