/* * Copyright 2017 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// Used to simulate a packet-based transport. class FakePacketTransport : public PacketTransportInternal { public: explicit FakePacketTransport(const std::string& transport_name)
: transport_name_(transport_name) {}
~FakePacketTransport() override { if (dest_ && dest_->dest_ == this) {
dest_->dest_ = nullptr;
}
}
// SetWritable, SetReceiving and SetDestination are the main methods that can // be used for testing, to simulate connectivity or lack thereof. void SetWritable(bool writable) { set_writable(writable); } void SetReceiving(bool receiving) { set_receiving(receiving); }
// Simulates the two transports connecting to each other. // If `asymmetric` is true this method only affects this FakePacketTransport. // If false, it affects `dest` as well. void SetDestination(FakePacketTransport* dest, bool asymmetric) { if (dest) {
dest_ = dest;
set_writable(true); if (!asymmetric) {
dest->SetDestination(this, true);
}
} else { // Simulates loss of connectivity, by asymmetrically forgetting dest_.
dest_ = nullptr;
set_writable(false);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.