Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
"license": "MIT",
"licenseFilename": "LICENSE",
"readmeFilename": "README.md",
"peerDependencies": {
"react-native-webrtc": "^1.75.1"
},
"devDependencies": {
"react-native-webrtc": "^1.75.1",
"react-native-background-timer": "^2.1.1"
}
}
15 changes: 12 additions & 3 deletions src/verto/Call.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {generateGUID, ENUM} from './utils';
import {Clipboard} from 'react-native';
import BackgroundTimer from 'react-native-background-timer';

BackgroundTimer.start();
//BackgroundTimer.start();

export default class Call {
constructor(direction, verto, params, mediaHandlers = {}) {
Expand Down Expand Up @@ -75,6 +75,9 @@ export default class Call {
this.ring();
}
}

this.causeCode = null;
this.cause = null;
}

bootstrapRealtimeConnection() {
Expand Down Expand Up @@ -264,7 +267,13 @@ export default class Call {

case ENUM.state.hangup:
if (isAfterRequesting && isBeforeHangup) {
this.broadcastMethod('verto.bye', {});
var params = {};
if (this.cause != null && this.causeCode != null)
params = { causeCode:this.causeCode, cause: this.cause };

this.broadcastMethod('verto.bye', params);
this.causeCode = null;
this.cause = null;
}

this.setState(ENUM.state.destroy);
Expand Down Expand Up @@ -333,7 +342,7 @@ export default class Call {
this.cause = params.cause;
}

if (!this.cause && !this.causeCode) {
if (this.cause === null && this.causeCode === null) {
this.cause = 'NORMAL_CLEARING';
}

Expand Down
8 changes: 4 additions & 4 deletions src/verto/VertoClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {generateGUID, ENUM} from './utils';
import {Params, defaultVertoCallbacks, eventType} from '../store';
import BackgroundTimer from 'react-native-background-timer';

BackgroundTimer.start();
//BackgroundTimer.start();
let sessionIDCache;

export default class VertinhoClient {
Expand Down Expand Up @@ -78,7 +78,7 @@ export default class VertinhoClient {
onWebSocketLoginSuccess: () => {},
onWebSocketLoginError: error =>
printError('Error reported by WebSocket login', error),
onPeerStreaming: () => {},
onPeerStreaming: (stream) => this.callbacks.onStreamReady(stream),
onPeerStreamingError: () => {},
...this.params,
...this.callbacks,
Expand Down Expand Up @@ -141,7 +141,7 @@ export default class VertinhoClient {
this.webSocket.onopen = () => {
if (this.retryingTimer) {
printWarning('Successfully WebSocket attempt to reconnect.');
clearTimeout(this.retryingTimer);
BackgroundTimer.clearTimeout(this.retryingTimer);
}

this.publish('login', {});
Expand Down Expand Up @@ -551,7 +551,7 @@ export default class VertinhoClient {

destroy() {
if (this.retryingTimer)
clearTimeout(this.retryingTimer);
BackgroundTimer.clearTimeout(this.retryingTimer);
if (this.socketReady()) {
this.webSocket.close();
this.purge();
Expand Down
18 changes: 15 additions & 3 deletions src/webrtc/FSRTCPeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import {RTCPeerConnection, RTCSessionDescription} from 'react-native-webrtc';
import BackgroundTimer from 'react-native-background-timer';

BackgroundTimer.start();
//BackgroundTimer.start();

export default class FSRTCPeerConnection {
constructor(options) {
Expand Down Expand Up @@ -79,14 +79,26 @@ export default class FSRTCPeerConnection {
}
};

peer.onaddstream = event => {
/* peer.onaddstream = event => {
const remoteMediaStream = event.stream;
if (onRemoteStream) {
onRemoteStream(remoteMediaStream);
}
};
peer.addStream(attachStream);*/

peer.ontrack = event => {
//const remoteMediaStream = event.stream;
const remoteMediaStream = event.streams[0];
if (onRemoteStream) {
onRemoteStream(remoteMediaStream);
}
};
peer.addStream(attachStream);

attachStream.getTracks().forEach(track => {
console.log('Peer add track ',track);
peer.addTrack(track, attachStream);
});

if (onOfferSDP) {
peer
Expand Down