internal UdpConnection(UdpSocket s, UdpConnectionMode m, UdpEndPoint ep) { socket = s; mode = m; endpoint = ep; stats = new UdpStats(); networkRtt = socket.Config.DefaultNetworkPing; aliasedRtt = socket.Config.DefaultAliasedPing; mtu = socket.Config.PacketSize; alwaysSendMtu = socket.Config.DefaultAlwaysSendMtu; state = UdpConnectionState.Connecting; recvTime = socket.GetCurrentTime(); sendTime = recvTime; sendWindow = new UdpRingBuffer <UdpHandle>(socket.Config.PacketWindow); this.networkPingFilterRttValues = new uint[socket.Config.NetworkPingMedianFilterSize]; this.networkPingFilterSortedIndices = new int[socket.Config.NetworkPingMedianFilterSize]; for (int i = 0; i < this.networkPingFilterSortedIndices.Length; ++i) { this.networkPingFilterSortedIndices[i] = i; } networkPingFilterNextIndexToReplace = 0; serializer = socket.CreateSerializer(); serializer.Connection = this; }
internal void OnPacket(UdpStream buffer) { // track stats stats.PacketReceived((uint)buffer.Length >> 3); socket.Statistics.PacketReceived((uint)buffer.Length >> 3); // set recv time of for last packet recvTime = socket.GetCurrentTime(); if ((buffer.Data[0] & 1) == 1) { OnObjectReceived(buffer); } else { OnCommandReceived(buffer); } }
internal UdpConnection(UdpSocket s, UdpConnectionMode m, UdpEndPoint ep) { socket = s; mode = m; endpoint = ep; stats = new UdpStats(); networkRtt = socket.Config.DefaultNetworkPing; aliasedRtt = socket.Config.DefaultAliasedPing; mtu = socket.Config.PacketSize; alwaysSendMtu = socket.Config.DefaultAlwaysSendMtu; state = UdpConnectionState.Connecting; recvTime = socket.GetCurrentTime(); sendTime = recvTime; sendWindow = new UdpRingBuffer <UdpHandle>(socket.Config.PacketWindow); serializer = socket.CreateSerializer(); serializer.Connection = this; }
internal UdpConnection(UdpSocket s, UdpConnectionMode m, UdpEndPoint ep) { socket = s; mode = m; endpoint = ep; stats = new UdpStats(); networkRtt = socket.Config.DefaultNetworkPing; aliasedRtt = socket.Config.DefaultAliasedPing; mtu = socket.Config.PacketSize; alwaysSendMtu = socket.Config.DefaultAlwaysSendMtu; state = UdpConnectionState.Connecting; recvTime = socket.GetCurrentTime(); sendTime = recvTime; sendWindow = new UdpRingBuffer<UdpHandle>(socket.Config.PacketWindow); serializer = socket.CreateSerializer(); serializer.Connection = this; }
internal UdpConnection(UdpSocket s, UdpConnectionMode m, UdpEndPoint ep) { socket = s; mode = m; endpoint = ep; stats = new UdpStats(); networkRtt = socket.Config.DefaultNetworkPing; aliasedRtt = socket.Config.DefaultAliasedPing; mtu = socket.Config.PacketSize; alwaysSendMtu = socket.Config.DefaultAlwaysSendMtu; state = UdpConnectionState.Connecting; recvTime = socket.GetCurrentTime(); sendTime = recvTime; sendWindow = new UdpRingBuffer<UdpHandle>(socket.Config.PacketWindow); this.networkPingFilterRttValues = new uint[socket.Config.NetworkPingMedianFilterSize]; this.networkPingFilterSortedIndices = new int[socket.Config.NetworkPingMedianFilterSize]; for (int i = 0; i < this.networkPingFilterSortedIndices.Length; ++i) { this.networkPingFilterSortedIndices[i] = i; } networkPingFilterNextIndexToReplace = 0; serializer = socket.CreateSerializer(); serializer.Connection = this; }