public NetReliableOrderedReceiver(NetConnection connection, int windowSize) : base(connection) { m_windowSize = windowSize; m_withheldMessages = new NetIncomingMessage[windowSize]; m_earlyReceived = new NetBitVector(windowSize); }
internal NetUnreliableSenderChannel(NetConnection connection, int windowSize) { m_connection = connection; m_windowSize = windowSize; m_windowStart = 0; m_sendStart = 0; m_receivedAcks = new NetBitVector(NetConstants.NumSequenceNumbers); m_queuedSends = new NetQueue <NetOutgoingMessage>(8); }
internal NetUnreliableSenderChannel(NetConnection connection, int windowSize) { m_connection = connection; m_windowSize = windowSize; m_windowStart = 0; m_sendStart = 0; m_receivedAcks = new NetBitVector(NetConstants.NumSequenceNumbers); m_queuedSends = new NetQueue<NetOutgoingMessage>(8); }
internal NetReliableSenderChannel(NetConnection connection, int windowSize) { m_connection = connection; m_windowSize = windowSize; m_windowStart = 0; m_sendStart = 0; m_receivedAcks = new NetBitVector(NetConstants.NumSequenceNumbers); m_storedMessages = new NetStoredReliableMessage[m_windowSize]; m_queuedSends = new NetQueue<NetOutgoingMessage>(8); m_resendDelay = m_connection.GetResendDelay(); }
internal NetReliableSenderChannel(NetConnection connection, int windowSize) { m_connection = connection; m_windowSize = windowSize; m_windowStart = 0; m_sendStart = 0; m_receivedAcks = new NetBitVector(NetConstants.NumSequenceNumbers); m_storedMessages = new NetStoredReliableMessage[m_windowSize]; m_queuedSends = new NetQueue <NetOutgoingMessage>(8); m_resendDelay = m_connection.GetResendDelay(); }
internal NetUnreliableSenderChannel(NetConnection connection, int windowSize, NetDeliveryMethod method) { m_connection = connection; m_windowSize = windowSize; m_windowStart = 0; m_sendStart = 0; m_receivedAcks = new NetBitVector(NetConstants.NumSequenceNumbers); m_queuedSends = new NetQueue<NetOutgoingMessage>(8); m_doFlowControl = true; if (method == NetDeliveryMethod.Unreliable && connection.Peer.Configuration.SuppressUnreliableUnorderedAcks == true) m_doFlowControl = false; }
internal NetReliableSenderChannel(NetConnection connection, int windowSize) { m_connection = connection; m_windowSize = windowSize; m_windowStart = 0; m_sendStart = 0; m_receivedAcks = new NetBitVector(NetConstants.NumSequenceNumbers); NetException.Assert(m_windowSize <= 64); // we do only have sizeof(ulong)*8 "used" bits in m_usedStoredMessages m_usedStoredMessages = 0; m_storedMessages = new NetStoredReliableMessage[m_windowSize]; m_queuedSends = new NetQueue <NetOutgoingMessage>(8); m_resendDelay = m_connection.GetResendDelay(); }
internal NetUnreliableSenderChannel(NetConnection connection, int windowSize, NetDeliveryMethod method) { m_connection = connection; m_windowSize = windowSize; m_windowStart = 0; m_sendStart = 0; m_receivedAcks = new NetBitVector(NetConstants.NumSequenceNumbers); m_queuedSends = new NetQueue <NetOutgoingMessage>(8); m_doFlowControl = true; if (method == NetDeliveryMethod.Unreliable && connection.Peer.Configuration.SuppressUnreliableUnorderedAcks == true) { m_doFlowControl = false; } }
public NetReliableUnorderedReceiver(NetConnection connection, int windowSize) : base(connection) { m_windowSize = windowSize; m_earlyReceived = new NetBitVector(windowSize); }
private void ExpectedReliableSequenceArrived(int reliableSlot, bool isFragment) { NetBitVector received = m_reliableReceived[reliableSlot]; int nextExpected = m_nextExpectedReliableSequence[reliableSlot]; if (received == null) { nextExpected = (nextExpected + 1) % NetConstants.NumSequenceNumbers; m_nextExpectedReliableSequence[reliableSlot] = (ushort)nextExpected; return; } received[(nextExpected + (NetConstants.NumSequenceNumbers / 2)) % NetConstants.NumSequenceNumbers] = false; // reset for next pass nextExpected = (nextExpected + 1) % NetConstants.NumSequenceNumbers; // // Release withheld messages // while (received[nextExpected] == true) { // it seems we've already received the next expected reliable sequence number // ordered? const int orderedSlotsStart = ((int)NetMessageType.UserReliableOrdered - (int)NetMessageType.UserReliableUnordered); if (reliableSlot >= orderedSlotsStart) { // ... then we should have a withheld message waiting // this should be a withheld message int orderedSlot = reliableSlot - orderedSlotsStart; bool foundWithheld = false; List <NetIncomingMessage> withheldList = m_withheldMessages[orderedSlot]; if (withheldList != null) { foreach (NetIncomingMessage wm in withheldList) { int wmSeqChan = wm.SequenceChannel; if (orderedSlot == wmSeqChan && wm.m_sequenceNumber == nextExpected) { // Found withheld message due for delivery m_owner.LogVerbose("Releasing withheld message " + wm); //Console.WriteLine("Releasing withheld message " + wm); // Accept, unless a fragment if (wm.m_fragmentationInfo == null) { m_owner.ReleaseMessage(wm); } foundWithheld = true; withheldList.Remove(wm); // advance next expected received[(nextExpected + (NetConstants.NumSequenceNumbers / 2)) % NetConstants.NumSequenceNumbers] = false; // reset for next pass nextExpected = (nextExpected + 1) % NetConstants.NumSequenceNumbers; break; } } } if (!foundWithheld) { // probably a fragment; we don't withhold those - advance anyway //Console.WriteLine("Withheld #" + nextExpected + " not found; probably a fragment!"); //received[(nextExpected + (NetConstants.NumSequenceNumbers / 2)) % NetConstants.NumSequenceNumbers] = false; // reset for next pass //nextExpected = (nextExpected + 1) % NetConstants.NumSequenceNumbers; throw new NetException("Withheld message not found!"); } } } m_nextExpectedReliableSequence[reliableSlot] = (ushort)nextExpected; }
public static void Run() { NetBitVector v = new NetBitVector(256); for (int i = 0; i < 256; i++) { v.Clear(); if (i > 42 && i < 65) v = new NetBitVector(256); if (!v.IsEmpty()) throw new NetException("bit vector fail 1"); v.Set(i, true); if (v.Get(i) == false) throw new NetException("bit vector fail 2"); if (v.IsEmpty()) throw new NetException("bit vector fail 3"); if (i != 79 && v.Get(79) == true) throw new NetException("bit vector fail 4"); int f = v.GetFirstSetIndex(); if (f != i) throw new NetException("bit vector fail 4"); } /* v = new NetBitVector(9); v.Clear(); v.Set(3, true); if (v.ToString() != "[000001000]") throw new NetException("NetBitVector.RotateDown failed"); v.RotateDown(); if (v.Get(3) == true || v.Get(2) == false || v.Get(4) == true) throw new NetException("NetBitVector.RotateDown failed 2"); if (v.ToString() != "[000000100]") throw new NetException("NetBitVector.RotateDown failed 3"); v.Set(0, true); v.RotateDown(); if (v.ToString() != "[100000010]") throw new NetException("NetBitVector.RotateDown failed 4"); v = new NetBitVector(38); v.Set(0, true); v.Set(1, true); v.Set(31, true); if (v.ToString() != "[00000010000000000000000000000000000011]") throw new NetException("NetBitVector.RotateDown failed 5"); v.RotateDown(); if (v.ToString() != "[10000001000000000000000000000000000001]") throw new NetException("NetBitVector.RotateDown failed 5"); */ Console.WriteLine("NetBitVector tests OK"); }