Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sweng-group-15
liowebrtc
Commits
1fd19586
Commit
1fd19586
authored
Dec 27, 2018
by
lazorfuzz
Browse files
channelOpen emit fix
parent
9a0a0d8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/peer.js
View file @
1fd19586
...
@@ -162,14 +162,14 @@ class Peer extends WildEmitter {
...
@@ -162,14 +162,14 @@ class Peer extends WildEmitter {
}
}
// Internal method registering handlers for a data channel and emitting events on the peer
// Internal method registering handlers for a data channel and emitting events on the peer
_observeDataChannel
(
channel
)
{
_observeDataChannel
(
channel
,
peer
)
{
const
self
=
this
;
const
self
=
this
;
channel
.
onclose
=
this
.
emit
.
bind
(
this
,
'
channelClose
'
,
channel
);
channel
.
onclose
=
this
.
emit
.
bind
(
this
,
'
channelClose
'
,
channel
);
channel
.
onerror
=
this
.
emit
.
bind
(
this
,
'
channelError
'
,
channel
);
channel
.
onerror
=
this
.
emit
.
bind
(
this
,
'
channelError
'
,
channel
);
channel
.
onmessage
=
(
event
)
=>
{
channel
.
onmessage
=
(
event
)
=>
{
self
.
emit
(
'
channelMessage
'
,
self
,
channel
.
label
,
JSON
.
parse
(
event
.
data
),
channel
,
event
);
self
.
emit
(
'
channelMessage
'
,
self
,
channel
.
label
,
JSON
.
parse
(
event
.
data
),
channel
,
event
);
};
};
channel
.
onopen
=
this
.
emit
.
bind
(
this
,
'
channelOpen
'
,
channel
,
this
);
channel
.
onopen
=
this
.
emit
.
bind
(
this
,
'
channelOpen
'
,
channel
,
peer
);
}
}
// Fetch or create a data channel by the given name
// Fetch or create a data channel by the given name
...
@@ -179,7 +179,7 @@ class Peer extends WildEmitter {
...
@@ -179,7 +179,7 @@ class Peer extends WildEmitter {
if
(
channel
)
return
channel
;
if
(
channel
)
return
channel
;
// if we don't have one by this label, create it
// if we don't have one by this label, create it
channel
=
this
.
channels
[
name
]
=
this
.
pc
.
createDataChannel
(
name
,
opts
);
channel
=
this
.
channels
[
name
]
=
this
.
pc
.
createDataChannel
(
name
,
opts
);
this
.
_observeDataChannel
(
channel
);
this
.
_observeDataChannel
(
channel
,
this
);
return
channel
;
return
channel
;
}
}
...
@@ -260,7 +260,7 @@ class Peer extends WildEmitter {
...
@@ -260,7 +260,7 @@ class Peer extends WildEmitter {
handleDataChannelAdded
(
channel
)
{
handleDataChannelAdded
(
channel
)
{
this
.
channels
[
channel
.
label
]
=
channel
;
this
.
channels
[
channel
.
label
]
=
channel
;
this
.
_observeDataChannel
(
channel
);
this
.
_observeDataChannel
(
channel
,
this
);
}
}
sendFile
(
file
)
{
sendFile
(
file
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment