opentok-react-native
Advanced tools
Comparing version 0.6.3 to 0.6.4
{ | ||
"name": "opentok-react-native", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "React Native components for OpenTok iOS and Android SDKs", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -71,2 +71,21 @@ import { reassignEvents } from './OTHelper'; | ||
const getConnectionStatus = (connectionStatus) => { | ||
switch(connectionStatus) { | ||
case 0: | ||
return "not connected"; | ||
case 1: | ||
return "connected"; | ||
case 2: | ||
return "connecting"; | ||
case 3: | ||
return "reconnecting"; | ||
case 4: | ||
return "disconnecting"; | ||
case 5: | ||
return "failed"; | ||
} | ||
}; | ||
const isConnected = (connectionStatus) => (getConnectionStatus(connectionStatus) === 'connected'); | ||
export { | ||
@@ -76,2 +95,4 @@ sanitizeSessionEvents, | ||
sanitizeCredentials, | ||
getConnectionStatus, | ||
isConnected, | ||
}; |
@@ -8,2 +8,4 @@ import React, { Component } from 'react'; | ||
import OTPublisherView from './views/OTPublisherView'; | ||
import { isNull } from 'underscore'; | ||
import { isConnected } from './helpers/OTSessionHelper'; | ||
@@ -31,3 +33,3 @@ const uuid = require('uuid/v4'); | ||
componentDidMount() { | ||
this.createPublisher(); | ||
this.createPublisher(); | ||
} | ||
@@ -70,11 +72,5 @@ componentDidUpdate(previousProps) { | ||
sessionConnectedHandler = () => { | ||
OT.publish(this.state.publisherId, (publishError) => { | ||
if (publishError) { | ||
handleError(publisherError); | ||
} else { | ||
this.setState({ | ||
publisher: true, | ||
}); | ||
} | ||
}); | ||
if (isNull(this.state.publisher)) { | ||
this.publish(); | ||
} | ||
} | ||
@@ -97,3 +93,19 @@ createPublisher() { | ||
OT.initPublisher(this.state.publisherId, publisherProperties); | ||
OT.getSessionInfo((session) => { | ||
if (!isNull(session) && isNull(this.state.publisher) && isConnected(session.connectionStatus)) { | ||
this.publish(); | ||
} | ||
}); | ||
} | ||
publish() { | ||
OT.publish(this.state.publisherId, (publishError) => { | ||
if (publishError) { | ||
handleError(publishError); | ||
} else { | ||
this.setState({ | ||
publisher: true, | ||
}); | ||
} | ||
}); | ||
} | ||
render() { | ||
@@ -100,0 +112,0 @@ const { publisher, publisherId } = this.state; |
@@ -5,6 +5,6 @@ import React, { Component, Children, cloneElement } from 'react'; | ||
import { setNativeEvents, removeNativeEvents, OT } from './OT'; | ||
import { sanitizeSessionEvents, sanitizeSignalData, sanitizeCredentials } from './helpers/OTSessionHelper'; | ||
import { sanitizeSessionEvents, sanitizeSignalData, sanitizeCredentials, getConnectionStatus } from './helpers/OTSessionHelper'; | ||
import { logOT } from './helpers/OTHelper'; | ||
import { handleError } from './OTError'; | ||
import { pick } from 'underscore'; | ||
import { pick, isNull } from 'underscore'; | ||
@@ -55,9 +55,12 @@ export default class OTSession extends Component { | ||
} else { | ||
OT.getSessionInfo((sessionInfo) => { | ||
this.setState({ | ||
sessionInfo, | ||
}); | ||
logOT(credentials.apiKey, credentials.sessionId, 'rn_on_connect', sessionInfo.connection.connectionId); | ||
const signalData = sanitizeSignalData(this.props.signal); | ||
OT.sendSignal(signalData, signalData.errorHandler); | ||
OT.getSessionInfo((session) => { | ||
if (!isNull(session)) { | ||
const sessionInfo = { ...session, connectionStatus: getConnectionStatus(session.connectionStatus)}; | ||
this.setState({ | ||
sessionInfo, | ||
}); | ||
logOT(credentials.apiKey, credentials.sessionId, 'rn_on_connect', session.connection.connectionId); | ||
const signalData = sanitizeSignalData(this.props.signal); | ||
OT.sendSignal(signalData, signalData.errorHandler); | ||
} | ||
}); | ||
@@ -64,0 +67,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
420833
44
9543
1