Skip to content

Commit

Permalink
tmp save
Browse files Browse the repository at this point in the history
  • Loading branch information
WangSoda committed Jan 4, 2021
1 parent 3eca790 commit c265fd5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
17 changes: 8 additions & 9 deletions lib/containers/ConnectContainer/ConnectContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,21 @@ function ConnectContainer() {
// console.log('from callee desc :>> ', desc);
dataChannelClient.setRemoteDescription(JSON.parse(desc));
}
// answer.then(
// (answerdesc: RTCSessionDescriptionInit) => {
// console.log('answerdesc :>> ', answerdesc);
// },
// (error) => {
// console.log('error :>> ', error);
// },
// );
});

dataChannelClient.createDataChannel();
dataChannelClient.setIceCandidateListener((ev: RTCPeerConnectionIceEvent) => {
// console.log('sodalog ev.candidate :>> ', ev.candidate);
if (ev.candidate) {
console.log('ev.candidate :>> ', ev.candidate);
}
});
dataChannelClient.createOffer((desc: RTCSessionDescriptionInit) => {
console.log('desc :>> ', desc);
setLocalOfferDescription(desc);
dataChannelClient.setLocalDescription(desc);
});
}, []);

const handleSend = () => {
rpc.emit('get-local-network-info', null);
};
Expand Down
1 change: 1 addition & 0 deletions lib/webrtc/WebRTCClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class WebRTCClient {
}

handleIceCandidate = (ev: RTCPeerConnectionIceEvent) => {
console.log('sodalog handle icecandidate');
if (this.onIceCandidate) {
this.onIceCandidate(ev);
}
Expand Down
12 changes: 10 additions & 2 deletions lib/webrtc/WebRTCDataChannelClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ interface gotRTCSessionDescriptionListener {
class WebRTCDataChannelClient extends WebRTCClient {
onGotDescription: gotRTCSessionDescriptionListener | undefined;

dataChannel: RTCDataChannel | undefined;

createDataChannel = () => {
this.peerConnection.createDataChannel('sendDataChannel');
this.dataChannel = this.peerConnection.createDataChannel('sendDataChannel');
this.dataChannel.onopen = () => {
console.log('data channel open');
};
}

createOffer = (onGotDescription?: gotRTCSessionDescriptionListener) => {
Expand All @@ -23,13 +28,16 @@ class WebRTCDataChannelClient extends WebRTCClient {
if (this.onGotDescription) {
this.onGotDescription(desc);
}
this.peerConnection.setLocalDescription(desc);
}

handleGotDescriptionError = (error: Error) => {
console.log('error :>> ', error);
}

setLocalDescription = (description: RTCSessionDescriptionInit) => {
this.peerConnection.setLocalDescription(description);
}

setRemoteDescriptionAndCreateAnswer = async (
description: RTCSessionDescriptionInit,
) => {
Expand Down

0 comments on commit c265fd5

Please sign in to comment.