mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 15:15:28 +00:00
Renamed "Negociated" to "Negotiated"
This commit is contained in:
@ -88,13 +88,13 @@ private:
|
|||||||
friend class PeerConnection;
|
friend class PeerConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RTC_CPP_EXPORT NegociatedDataChannel final : public DataChannel {
|
class RTC_CPP_EXPORT NegotiatedDataChannel final : public DataChannel {
|
||||||
public:
|
public:
|
||||||
NegociatedDataChannel(std::weak_ptr<PeerConnection> pc, uint16_t stream, string label,
|
NegotiatedDataChannel(std::weak_ptr<PeerConnection> pc, uint16_t stream, string label,
|
||||||
string protocol, Reliability reliability);
|
string protocol, Reliability reliability);
|
||||||
NegociatedDataChannel(std::weak_ptr<PeerConnection> pc, std::weak_ptr<SctpTransport> transport,
|
NegotiatedDataChannel(std::weak_ptr<PeerConnection> pc, std::weak_ptr<SctpTransport> transport,
|
||||||
uint16_t stream);
|
uint16_t stream);
|
||||||
~NegociatedDataChannel();
|
~NegotiatedDataChannel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void open(std::shared_ptr<SctpTransport> transport) override;
|
void open(std::shared_ptr<SctpTransport> transport) override;
|
||||||
|
@ -235,20 +235,20 @@ void DataChannel::incoming(message_ptr message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NegociatedDataChannel::NegociatedDataChannel(std::weak_ptr<PeerConnection> pc, uint16_t stream,
|
NegotiatedDataChannel::NegotiatedDataChannel(std::weak_ptr<PeerConnection> pc, uint16_t stream,
|
||||||
string label, string protocol, Reliability reliability)
|
string label, string protocol, Reliability reliability)
|
||||||
: DataChannel(pc, stream, std::move(label), std::move(protocol), std::move(reliability)) {}
|
: DataChannel(pc, stream, std::move(label), std::move(protocol), std::move(reliability)) {}
|
||||||
|
|
||||||
NegociatedDataChannel::NegociatedDataChannel(std::weak_ptr<PeerConnection> pc,
|
NegotiatedDataChannel::NegotiatedDataChannel(std::weak_ptr<PeerConnection> pc,
|
||||||
std::weak_ptr<SctpTransport> transport,
|
std::weak_ptr<SctpTransport> transport,
|
||||||
uint16_t stream)
|
uint16_t stream)
|
||||||
: DataChannel(pc, stream, "", "", {}) {
|
: DataChannel(pc, stream, "", "", {}) {
|
||||||
mSctpTransport = transport;
|
mSctpTransport = transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
NegociatedDataChannel::~NegociatedDataChannel() {}
|
NegotiatedDataChannel::~NegotiatedDataChannel() {}
|
||||||
|
|
||||||
void NegociatedDataChannel::open(shared_ptr<SctpTransport> transport) {
|
void NegotiatedDataChannel::open(shared_ptr<SctpTransport> transport) {
|
||||||
mSctpTransport = transport;
|
mSctpTransport = transport;
|
||||||
|
|
||||||
uint8_t channelType;
|
uint8_t channelType;
|
||||||
@ -290,7 +290,7 @@ void NegociatedDataChannel::open(shared_ptr<SctpTransport> transport) {
|
|||||||
transport->send(make_message(buffer.begin(), buffer.end(), Message::Control, mStream));
|
transport->send(make_message(buffer.begin(), buffer.end(), Message::Control, mStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NegociatedDataChannel::processOpenMessage(message_ptr message) {
|
void NegotiatedDataChannel::processOpenMessage(message_ptr message) {
|
||||||
auto transport = mSctpTransport.lock();
|
auto transport = mSctpTransport.lock();
|
||||||
if (!transport)
|
if (!transport)
|
||||||
throw std::runtime_error("DataChannel has no transport");
|
throw std::runtime_error("DataChannel has no transport");
|
||||||
|
@ -663,7 +663,7 @@ void PeerConnection::forwardMessage(message_ptr message) {
|
|||||||
if (message->type == Message::Control && *message->data() == dataChannelOpenMessage &&
|
if (message->type == Message::Control && *message->data() == dataChannelOpenMessage &&
|
||||||
stream % 2 == remoteParity) {
|
stream % 2 == remoteParity) {
|
||||||
|
|
||||||
channel = std::make_shared<NegociatedDataChannel>(shared_from_this(), sctpTransport,
|
channel = std::make_shared<NegotiatedDataChannel>(shared_from_this(), sctpTransport,
|
||||||
stream);
|
stream);
|
||||||
channel->onOpen(weak_bind(&PeerConnection::triggerDataChannel, this,
|
channel->onOpen(weak_bind(&PeerConnection::triggerDataChannel, this,
|
||||||
weak_ptr<DataChannel>{channel}));
|
weak_ptr<DataChannel>{channel}));
|
||||||
@ -835,7 +835,7 @@ shared_ptr<DataChannel> PeerConnection::emplaceDataChannel(Description::Role rol
|
|||||||
init.negotiated
|
init.negotiated
|
||||||
? std::make_shared<DataChannel>(shared_from_this(), stream, std::move(label),
|
? std::make_shared<DataChannel>(shared_from_this(), stream, std::move(label),
|
||||||
std::move(init.protocol), std::move(init.reliability))
|
std::move(init.protocol), std::move(init.reliability))
|
||||||
: std::make_shared<NegociatedDataChannel>(shared_from_this(), stream, std::move(label),
|
: std::make_shared<NegotiatedDataChannel>(shared_from_this(), stream, std::move(label),
|
||||||
std::move(init.protocol),
|
std::move(init.protocol),
|
||||||
std::move(init.reliability));
|
std::move(init.reliability));
|
||||||
mDataChannels.emplace(std::make_pair(stream, channel));
|
mDataChannels.emplace(std::make_pair(stream, channel));
|
||||||
|
@ -221,7 +221,7 @@ void test_connectivity() {
|
|||||||
auto negotiated2 = pc2->createDataChannel("negoctated", init);
|
auto negotiated2 = pc2->createDataChannel("negoctated", init);
|
||||||
|
|
||||||
if (!negotiated1->isOpen() || !negotiated2->isOpen())
|
if (!negotiated1->isOpen() || !negotiated2->isOpen())
|
||||||
throw runtime_error("Negociated DataChannel is not open");
|
throw runtime_error("Negotiated DataChannel is not open");
|
||||||
|
|
||||||
std::atomic<bool> received = false;
|
std::atomic<bool> received = false;
|
||||||
negotiated2->onMessage([&received](const variant<binary, string> &message) {
|
negotiated2->onMessage([&received](const variant<binary, string> &message) {
|
||||||
@ -239,7 +239,7 @@ void test_connectivity() {
|
|||||||
this_thread::sleep_for(1s);
|
this_thread::sleep_for(1s);
|
||||||
|
|
||||||
if (!received)
|
if (!received)
|
||||||
throw runtime_error("Negociated DataChannel failed");
|
throw runtime_error("Negotiated DataChannel failed");
|
||||||
|
|
||||||
// Delay close of peer 2 to check closing works properly
|
// Delay close of peer 2 to check closing works properly
|
||||||
pc1->close();
|
pc1->close();
|
||||||
|
@ -232,7 +232,7 @@ void test_turn_connectivity() {
|
|||||||
auto negotiated2 = pc2->createDataChannel("negoctated", init);
|
auto negotiated2 = pc2->createDataChannel("negoctated", init);
|
||||||
|
|
||||||
if (!negotiated1->isOpen() || !negotiated2->isOpen())
|
if (!negotiated1->isOpen() || !negotiated2->isOpen())
|
||||||
throw runtime_error("Negociated DataChannel is not open");
|
throw runtime_error("Negotiated DataChannel is not open");
|
||||||
|
|
||||||
std::atomic<bool> received = false;
|
std::atomic<bool> received = false;
|
||||||
negotiated2->onMessage([&received](const variant<binary, string> &message) {
|
negotiated2->onMessage([&received](const variant<binary, string> &message) {
|
||||||
@ -250,7 +250,7 @@ void test_turn_connectivity() {
|
|||||||
this_thread::sleep_for(1s);
|
this_thread::sleep_for(1s);
|
||||||
|
|
||||||
if (!received)
|
if (!received)
|
||||||
throw runtime_error("Negociated DataChannel failed");
|
throw runtime_error("Negotiated DataChannel failed");
|
||||||
|
|
||||||
// Delay close of peer 2 to check closing works properly
|
// Delay close of peer 2 to check closing works properly
|
||||||
pc1->close();
|
pc1->close();
|
||||||
|
Reference in New Issue
Block a user