internal void Reset() { Dead = false; Recycled = false; State = ConnectionState.Disconnected; Socket = null; EndPoint = null; HailStatus = new MessageStatus(); MTUStatus = new MessageStatus(); ConnectionChallenge = 0; ChallengeDifficulty = 0; ChallengeAnswer = 0; LastMessageOut = DateTime.MinValue; LastMessageIn = DateTime.MinValue; ConnectionStarted = DateTime.MinValue; SmoothRoundtrip = 0; Roundtrip = 500; LowestRoundtrip = 500; RoundtripVarience = 0; HighestRoundtripVarience = 0; MTU = 0; HandshakeLastSendTime = DateTime.MinValue; HandshakeResendAttempts = 0; HeartbeatChannel.Reset(); Merger.Clear(); PreConnectionChallengeTimestamp = 0; PreConnectionChallengeCounter = 0; PreConnectionChallengeIV = 0; OutgoingPackets = 0; OutgoingWirePackets = 0; OutgoingUserBytes = 0; OutgoingTotalBytes = 0; OutgoingResentPackets = 0; OutgoingConfirmedPackets = 0; IncomingPackets = 0; IncomingWirePackets = 0; IncomingUserBytes = 0; IncomingTotalBytes = 0; IncomingDuplicatePackets = 0; IncomingDuplicateTotalBytes = 0; IncomingDuplicateUserBytes = 0; }
internal void Release() { if (Config.EnableHeartbeats) { // Release all memory from the heartbeat channel HeartbeatChannel.Release(); } if (Config.EnablePacketMerging) { // Try to get one last flush ArraySegment <byte>?mergedPayload = Merger.TryFlush(); if (mergedPayload != null) { SendInternal(mergedPayload.Value, true); } // Clean the merger Merger.Clear(); } // // Reset all channels, releasing memory etc for (int i = 0; i < Channels.Length; i++) { if (Channels[i] != null) { // Grab a ref to the channel IChannel channel = Channels[i]; // Set the channel to null. Preventing further polls Channels[i] = null; if (Config.ReuseChannels) { // Return old channel to pool Socket.ChannelPool.Return(channel); } else { // Simply release the memory channel.Release(); } } } }