Skip to content

Commit

Permalink
Correct webrtc callbacks to match new pions api
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmcd committed Nov 19, 2018
1 parent ec7138d commit 8a10808
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
command: |
set -e
go get -v .
go get -u github.com/pions/webrtc
go get golang.org/x/lint/golint
golint
go test
Expand Down
6 changes: 2 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ func (cs *clientSession) run() (err error) {
return
}

cs.dc.Lock()
cs.dc.OnOpen = cs.dataChannelOnOpen()
cs.dc.Onmessage = cs.dataChannelOnMessage()
cs.dc.Unlock()
cs.dc.OnOpen(cs.dataChannelOnOpen())
cs.dc.OnMessage(cs.dataChannelOnMessage())

if cs.offer, err = sd.Decode(cs.offerString); err != nil {
log.Println(err)
Expand Down
8 changes: 3 additions & 5 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ func (hs *hostSession) dataChannelOnMessage() func(payload datachannel.Payload)
func (hs *hostSession) onDataChannel() func(dc *webrtc.RTCDataChannel) {
return func(dc *webrtc.RTCDataChannel) {
hs.dc = dc
dc.Lock()
defer dc.Unlock()
dc.OnOpen = hs.dataChannelOnOpen()
dc.Onmessage = hs.dataChannelOnMessage()
dc.OnOpen(hs.dataChannelOnOpen())
dc.OnMessage(hs.dataChannelOnMessage())
}
}

Expand All @@ -186,7 +184,7 @@ func (hs *hostSession) mustReadStdin() (string, error) {
}

func (hs *hostSession) createOffer() (err error) {
hs.pc.OnDataChannel = hs.onDataChannel()
hs.pc.OnDataChannel(hs.onDataChannel())

// Create an offer to send to the browser
offer, err := hs.pc.CreateOffer(nil)
Expand Down
4 changes: 2 additions & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func (s *session) createPeerConnection() (err error) {
// if s.pc.OnDataChannel == nil {
// return errors.New("Couldn't create a peerConnection")
// }
s.pc.OnICEConnectionStateChange = func(connectionState ice.ConnectionState) {
s.pc.OnICEConnectionStateChange(func(connectionState ice.ConnectionState) {
log.Printf("ICE Connection State has changed: %s\n", connectionState.String())
}
})
return
}

0 comments on commit 8a10808

Please sign in to comment.