weixin_39749243
weixin_39749243
2020-11-30 20:07

"extra" data of initiator is undefined when participants receive the data onMessage()

Suppose UserA created the room and UserB joins the room. Now, if UserA send the text message to UserB and UserB receives the data in onMessage()


connection.onmessage = function(e)
  {
    console.log('onmessage : ' + e.extra.color);
  };

e.extra is undefined (both in Firefox and Chrome). Tested with sender as Firefox and receiver as Chrome, as well as vice-versa. [When UserB sends to UserA, its all fine]

Extra data is saved as follows :


connection.extra = {
    username : name,
    color : 'teal'
  }

and then the call to open() or join() is made.

Logs for UserA who created the room :


Creating connection with channel-id : text
rmc3.min.js:17 FileError {code: 2, name: "SecurityError", message: "It was determined that certain files are unsafe fo… too many calls are being made on file resources."}
rmc3.min.js:16 socket.io connection is opened.
text.html:140 disabling input activities
text.html:145 all input activies disabled
text.html:237 room has been created
text.html:280 called onUserStatusChanged
text.html:290 User just joined : oo59mk1uxrcu01emc301
rmc3.min.js:18 Your candidate pairs: candidate:3581707038 1 udp 2113937151 192.168.0.6 48998 typ host generation 0 ufrag Jm3d5EAxFA4v+7m2
rmc3.min.js:18 Your candidate pairs: candidate:842163049 1 udp 1677729535 1.23.174.83 48998 typ srflx raddr 192.168.0.6 rport 48998 generation 0 ufrag Jm3d5EAxFA4v+7m2
rmc3.min.js:18 Your candidate pairs: candidate:3350145135 1 udp 33562367 64.251.31.85 65034 typ relay raddr 1.23.174.83 rport 48998 generation 0 ufrag Jm3d5EAxFA4v+7m2
rmc3.min.js:18 Your candidate pairs: candidate:3350145135 1 udp 33562623 64.251.31.85 52069 typ relay raddr 1.23.174.83 rport 48998 generation 0 ufrag Jm3d5EAxFA4v+7m2
text.html:280 called onUserStatusChanged
text.html:290 User just joined : oo59mk1uxrcu01emc301
rmc3.min.js:16 Remote peer's sdp: v=0
o=mozilla...THIS_IS_SDPARTA-38.0 191835829948174255 0 IN IP4 0.0.0.0
s=-
t=0 0
a=fingerprint:sha-256 24:7D:89:CC:B2:F1:C4:74:E5:5D:36:4D:E6:51:27:34:E1:82:29:8B:E6:37:F7:5C:67:00:5A:E7:FE:5C:69:35
a=ice-options:trickle
a=msid-semantic:WMS *
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
a=sendrecv
a=ice-pwd:7bbf2e1a42b8bfe873b3acfba9555890
a=ice-ufrag:a29c4783
a=mid:data
a=sctpmap:5000 webrtc-datachannel 256
a=setup:active

text.html:280 called onUserStatusChanged
text.html:290 User just joined : oo59mk1uxrcu01emc301
rmc3.min.js:16 Remote peer's candidate pairs: candidate:0 1 UDP 2122252543 192.168.0.6 48136 typ host
text.html:280 called onUserStatusChanged
text.html:290 User just joined : oo59mk1uxrcu01emc301
rmc3.min.js:16 Remote peer's candidate pairs: candidate:1 1 UDP 1686110207 1.23.174.83 48136 typ srflx raddr 192.168.0.6 rport 48136
text.html:280 called onUserStatusChanged
text.html:290 User just joined : oo59mk1uxrcu01emc301
rmc3.min.js:16 Remote peer's candidate pairs: candidate:3 1 UDP 92274687 64.251.31.85 50217 typ relay raddr 64.251.31.85 rport 50217
text.html:280 called onUserStatusChanged
text.html:290 User just joined : oo59mk1uxrcu01emc301
rmc3.min.js:16 Remote peer's candidate pairs: candidate:5 1 UDP 92274687 64.251.31.85 53308 typ relay raddr 64.251.31.85 rport 53308
text.html:276 connection open
text.html:271 onmessage : teal
text.html:195 new message : This message is sent by participant. Its fine
text.html:196 teal
125text.html:250 Keycode obtained : [object Object]
text.html:258 sending : This message is sent by initiator. Its extra will not be delivered properly but message reaches fine
text.html:195 new message : This message is sent by initiator. Its extra will not be delivered properly but message reaches fine
text.html:196 teal
2text.html:250 Keycode obtained : [object Object]

Logs for UserB who joined the room :



"Creating connection with channel-id : text" text.html:101:2
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. text.html
"socket.io connection is opened." rmc3.min.js:16:7778
"User selected existing room : wonder" text.html:162:4
"called onUserStatusChanged" text.html:280:6
"User just joined : wonder" text.html:290:8
"Remote peer's sdp:" "v=0

o=- 2281764698840525658 2 IN IP4 127.0.0.1

s=-

t=0 0

a=msid-semantic: WMS

m=application 9 DTLS/SCTP 5000

c=IN IP4 0.0.0.0

a=ice-ufrag:Jm3d5EAxFA4v+7m2

a=ice-pwd:fO9Fml0dw4ynAfNhtpGNITAM

a=fingerprint:sha-256 0C:69:86:BA:89:D7:F4:F1:64:94:E9:AF:57:4B:41:1C:08:8F:6D:26:4F:C0:92:56:E6:34:D1:0F:21:42:F7:DD

a=setup:actpass

a=mid:data

a=sctpmap:5000 webrtc-datachannel 1024

" rmc3.min.js:16:17832
"called onUserStatusChanged" text.html:280:6
"User just joined : wonder" text.html:290:8
"Remote peer's candidate pairs:" "candidate:3581707038 1 udp 2113937151 192.168.0.6 48998 typ host generation 0 ufrag Jm3d5EAxFA4v+7m2" rmc3.min.js:16:18026
"called onUserStatusChanged" text.html:280:6
"User just joined : wonder" text.html:290:8
"Remote peer's candidate pairs:" "candidate:842163049 1 udp 1677729535 1.23.174.83 48998 typ srflx raddr 192.168.0.6 rport 48998 generation 0 ufrag Jm3d5EAxFA4v+7m2" rmc3.min.js:16:18026
"Your candidate pairs:" "candidate:0 1 UDP 2122252543 192.168.0.6 48136 typ host" rmc3.min.js:18:6852
"Your candidate pairs:" "candidate:1 1 UDP 1686110207 1.23.174.83 48136 typ srflx raddr 192.168.0.6 rport 48136" rmc3.min.js:18:6852
"called onUserStatusChanged" text.html:280:6
"User just joined : wonder" text.html:290:8
"Remote peer's candidate pairs:" "candidate:3350145135 1 udp 33562367 64.251.31.85 65034 typ relay raddr 1.23.174.83 rport 48998 generation 0 ufrag Jm3d5EAxFA4v+7m2" rmc3.min.js:16:18026
"called onUserStatusChanged" text.html:280:6
"User just joined : wonder" text.html:290:8
"Remote peer's candidate pairs:" "candidate:3350145135 1 udp 33562623 64.251.31.85 52069 typ relay raddr 1.23.174.83 rport 48998 generation 0 ufrag Jm3d5EAxFA4v+7m2" rmc3.min.js:16:18026
"Your candidate pairs:" "candidate:3 1 UDP 92274687 64.251.31.85 50217 typ relay raddr 64.251.31.85 rport 50217" rmc3.min.js:18:6852
"Your candidate pairs:" "candidate:5 1 UDP 92274687 64.251.31.85 53308 typ relay raddr 64.251.31.85 rport 53308" rmc3.min.js:18:6852
"connection open" text.html:276:4
"Keycode obtained : [object Object]" text.html:250:4
"sending : This message is sent by participant. Its fine" text.html:258:4
"new message : This message is sent by participant. Its fine" text.html:195:4
"teal" text.html:196:4
"onmessage : undefined" text.html:271:4
"new message : This message is sent by initiator. Its extra will not be delivered properly but message reaches fine" text.html:195:4
undefined text.html:196:4
TypeError: conn.extra.username is undefined text.html:197:8
"Keycode obtained : [object Object]"

该提问来源于开源项目:muaz-khan/RTCMultiConnection

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答

为你推荐

换一换