History

started work on sending nack packets from client

wangyix committed 12 years ago

Commit 8cd5ec31 parent 5461a065 files · +85 −3Browse files

Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all

Unified · Split

interface/src/Application.cpp+58−1
@@ -167,7 +167,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 166 unmodified lines
167167 _applicationOverlay(),
168168 _runningScriptsWidget(new RunningScriptsWidget(_window)),
169169 _runningScriptsWidgetWasVisible(false),
170− _trayIcon(new QSystemTrayIcon(_window))
170+ _trayIcon(new QSystemTrayIcon(_window)),
171+ _lastNackTime(usecTimestampNow())
171172 {
172173 // read the ApplicationInfo.ini file for Name/Version/Domain information
173174 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
@@ -2091,7 +2092,63 @@ void Application::updateMyAvatar(float deltaTime) { · 1917 unmodified lines
20912092 _lastQueriedViewFrustum = _viewFrustum;
20922093 }
20932094 }
2095+
2096+// sent a nack packet containing missing sequence numbers of received packets
2097+{
2098+ quint64 now = usecTimestampNow();
2099+ quint64 sinceLastNack = now - _lastNackTime;
2100+ const quint64 TOO_LONG_SINCE_LAST_NACK = 100 * MSECS_PER_SECOND;
2101+ if (sinceLastNack > TOO_LONG_SINCE_LAST_NACK) {
2102+ _lastNackTime = now;
2103+
2104+ //_octreeServerSceneStats-
2105+ }
20942106 }
2107+}
2108+
2109+
2110+void Application::sendNack() {
2111+ /*
2112+ // now that we know the node ID, let's add these stats to the stats for that node...
2113+ _octreeSceneStatsLock.lockForWrite();
2114+ if (_octreeServerSceneStats.find(nodeUUID) != _octreeServerSceneStats.end()) {
2115+ OctreeSceneStats& stats = _octreeServerSceneStats[nodeUUID];
2116+ stats.trackIncomingOctreePacket(packet, wasStatsPacket, sendingNode->getClockSkewUsec());
2117+ }
2118+ _octreeSceneStatsLock.unlock();
2119+ */
2120+
2121+ char packet[MAX_PACKET_SIZE];
2122+ NodeList* nodeList = NodeList::getInstance();
2123+
2124+ // iterates thru all nodes in NodeList
2125+ foreach(const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
2126+
2127+ char* dataAt = packet;
2128+ int bytesRemaining = MAX_PACKET_SIZE;
2129+
2130+ int numBytesPacketHeader = populatePacketHeader(packet, PacketTypeOctreeDataNack, node->getUUID());
2131+ dataAt += numBytesPacketHeader;
2132+ bytesRemaining -= numBytesPacketHeader;
2133+
2134+
2135+
2136+ uint16_t numSequenceNumbers;
2137+
2138+
2139+
2140+
2141+ OctreeSceneStats& stats = _octreeServerSceneStats[node->getUUID()];
2142+ int numSequenceNumbersAvailable = stats.getNumSequenceNumberToNack();
2143+
2144+
2145+ // make sure we still have an active socket
2146+ nodeList->writeUnverifiedDatagram(reinterpret_cast<const char*>(queryPacket), packetLength, node);
2147+ }
2148+}
2149+
2150+
2151+
20952152
20962153 void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
20972154

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t