@@ -75,8 +75,13 @@ struct CloseMessage {
75
75
};
76
76
#pragma pack(pop)
77
77
78
- LogCounter COUNTER_USERNEG_OPEN_MESSAGE (
79
- plog::warning, " Number of open messages for a user-negotiated DataChannel received" );
78
+ bool DataChannel::IsOpenMessage (message_ptr message) {
79
+ if (message->type != Message::Control)
80
+ return false ;
81
+
82
+ auto raw = reinterpret_cast <const uint8_t *>(message->data ());
83
+ return !message->empty () && raw[0 ] == MESSAGE_OPEN;
84
+ }
80
85
81
86
DataChannel::DataChannel (weak_ptr<PeerConnection> pc, uint16_t stream, string label,
82
87
string protocol, Reliability reliability)
@@ -193,8 +198,7 @@ void DataChannel::open(shared_ptr<SctpTransport> transport) {
193
198
}
194
199
195
200
void DataChannel::processOpenMessage (message_ptr) {
196
- PLOG_DEBUG << " Received an open message for a user-negotiated DataChannel, ignoring" ;
197
- COUNTER_USERNEG_OPEN_MESSAGE++;
201
+ PLOG_WARNING << " Received an open message for a user-negotiated DataChannel, ignoring" ;
198
202
}
199
203
200
204
bool DataChannel::outgoing (message_ptr message) {
@@ -218,7 +222,7 @@ bool DataChannel::outgoing(message_ptr message) {
218
222
}
219
223
220
224
void DataChannel::incoming (message_ptr message) {
221
- if (!message)
225
+ if (!message || mIsClosed )
222
226
return ;
223
227
224
228
switch (message->type ) {
@@ -261,12 +265,6 @@ NegotiatedDataChannel::NegotiatedDataChannel(weak_ptr<PeerConnection> pc, uint16
261
265
string label, string protocol, Reliability reliability)
262
266
: DataChannel(pc, stream, std::move(label), std::move(protocol), std::move(reliability)) {}
263
267
264
- NegotiatedDataChannel::NegotiatedDataChannel (weak_ptr<PeerConnection> pc,
265
- weak_ptr<SctpTransport> transport, uint16_t stream)
266
- : DataChannel(pc, stream, " " , " " , {}) {
267
- mSctpTransport = transport;
268
- }
269
-
270
268
NegotiatedDataChannel::~NegotiatedDataChannel () {}
271
269
272
270
void NegotiatedDataChannel::open (shared_ptr<SctpTransport> transport) {
@@ -314,7 +312,23 @@ void NegotiatedDataChannel::open(shared_ptr<SctpTransport> transport) {
314
312
transport->send (make_message (buffer.begin (), buffer.end (), Message::Control, mStream ));
315
313
}
316
314
317
- void NegotiatedDataChannel::processOpenMessage (message_ptr message) {
315
+ void NegotiatedDataChannel::processOpenMessage (message_ptr) {
316
+ PLOG_WARNING << " Received an open message for a locally-created DataChannel, ignoring" ;
317
+ }
318
+
319
+ IncomingDataChannel::IncomingDataChannel (weak_ptr<PeerConnection> pc,
320
+ weak_ptr<SctpTransport> transport, uint16_t stream)
321
+ : DataChannel(pc, stream, " " , " " , {}) {
322
+ mSctpTransport = transport;
323
+ }
324
+
325
+ IncomingDataChannel::~IncomingDataChannel () {}
326
+
327
+ void IncomingDataChannel::open (shared_ptr<SctpTransport>) {
328
+ // Ignore
329
+ }
330
+
331
+ void IncomingDataChannel::processOpenMessage (message_ptr message) {
318
332
std::unique_lock lock (mMutex );
319
333
auto transport = mSctpTransport .lock ();
320
334
if (!transport)
0 commit comments