What is the function of label in createDataChannel and how to use it correctly?

Viewed 388

I am using WebRTC, for createDataChannel, what is the function of parameter label? I didn't find find any info about it.

The API from MDN

RTCDataChannel createDataChannel (DOMString label, optional RTCDataChannelInit dataChannelDict);


And how to use it correctly?

For example, A is person who send offer, and B is the person who accept the offer, and they want to send message to each other, when they use createDataChannel,

(Note ----> means ability to sent message)

(1) Should they use different label?

createDataChannel(LabelA)
  A ---------------------------> B
    <---------------------------
                         createDataChannel(LabelB)

(2) Or they should use same label:

createDataChannel(Same)
  A ---------------------------> B
    <---------------------------
                         createDataChannel(Same)

(3) Or only A needs createDataChannel, but B still can send message back to A. Because this example is this case.

createDataChannel(LabelA)
  A --------------------------> B
    <--------------------------

Which case is correct use case? Thanks

2 Answers
Related