Skip to content

Commit

Permalink
Example update
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiaohang000 committed Jan 14, 2021
1 parent 358a854 commit c591777
Show file tree
Hide file tree
Showing 75 changed files with 18,891 additions and 1,745 deletions.
3 changes: 0 additions & 3 deletions example/.babelrc

This file was deleted.

4 changes: 4 additions & 0 deletions example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
65 changes: 42 additions & 23 deletions example/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,69 @@
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
; These should not be required directly
; require from fbjs/lib instead: require('fbjs/lib/warning')
node_modules/warning/.*

; Ignore polyfills
.*/Libraries/polyfills/.*
; Flow doesn't support platforms
.*/Libraries/Utilities/LoadingView.js

; Ignore metro
.*/node_modules/metro/.*
[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/interface.js
node_modules/react-native/flow/
node_modules/react-native/flow-github/

[options]
emoji=true

module.system=haste

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js
module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.65.0
^0.122.0
8 changes: 7 additions & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
Expand All @@ -40,6 +39,7 @@ yarn-error.log
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
Expand All @@ -51,3 +51,9 @@ buck-out/
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
6 changes: 6 additions & 0 deletions example/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
};
9 changes: 1 addition & 8 deletions example/app/App.js → example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Modal,
Keyboard
} from 'react-native';
import { JMRTCViewController,JMRTCView} from 'jmrtc-react-native'
import { JMRTCViewController,JMRTCView} from 'jmrtc-react-native-ys'
import JMessage from 'jmessage-react-plugin'

import LoginPage from './LoginPage'
Expand Down Expand Up @@ -41,13 +41,6 @@ export default class App extends Component {
}

render() {
// JMRTCViewController.initEngine( (res) => {
// console.log(JSON.stringify(res))
// }, () => {

// });

// JMRTCViewController.releaseEngine()
return (
<View style={styles.container}>
{ this.state.isLogin ?
Expand Down
File renamed without changes.
File renamed without changes.
34 changes: 17 additions & 17 deletions example/app/LoginPage.js → example/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class LoginPage extends Component {

onPress() {

JMessage.login({username: this.state.username, password: this.state.password}, () => {
JMessage.login({username: "ys003", password: "123456"}, () => {
Alert.alert('login success')
this.props.onLoginSuccess()
}, (error) => {
Expand All @@ -98,7 +98,7 @@ export default class LoginPage extends Component {
}

register() {
JMessage.register({username: this.state.username, password: this.state.password}, () => {
JMessage.register({username: "ys003", password: "123456"}, () => {
Alert.alert('register success')
}, (error) => {
Alert.alert('register fail', JSON.stringify(error))
Expand Down Expand Up @@ -127,24 +127,24 @@ export default class LoginPage extends Component {
<Button
style={{width: 100, height: 20, position: "absolute", left: 0, top: 1000}}
onPress={this.register}
title="注册">
title="注册111">
</Button>
</View>
);
}
}

const styles = StyleSheet.create({
inputView: {
margin: 10,
},
loginBtn: {
color: "#ffffff",
height: 30,
backgroundColor: "#cccccc",
},
button: {
backgroundColor: '#FF3366',
borderColor: '#FF3366'
},
});
// const styles = StyleSheet.create({
// inputView: {
// margin: 10,
// },
// loginBtn: {
// color: "#ffffff",
// height: 30,
// backgroundColor: "#cccccc",
// },
// button: {
// backgroundColor: '#FF3366',
// borderColor: '#FF3366'
// },
// });
105 changes: 65 additions & 40 deletions example/app/RTCComponent.js → example/RTCComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import {
Alert,
Platform
} from 'react-native';
import { JMRTCViewController} from 'jmrtc-react-native'
import { JMRTCViewController} from 'jmrtc-react-native-ys'
import {FormButton} from './LoginPage'

import CallAlert from './CallAlert'
import RTCVideoView from './RTCVideoView'
export default class RTCComponent extends Component {

// callStatues = 'none' | calling
isMuted = false;

constructor(props) {
super(props)
this.state = {
Expand All @@ -30,37 +31,75 @@ export default class RTCComponent extends Component {
targetUsername: '',
myUsername: '',
}

}

componentDidMount() {
}

startCallUser(){
JMRTCViewController.releaseEngine()
JMRTCViewController.initEngine( (res) => {
console.log('initEngine ' + JSON.stringify(res))

JMRTCViewController.startCallUsers(
{ usernames: [this.state.username], type: "video" },
res => {
console.log("rtccomponent username" + this.props.myUsername + "targetUsername" + this.state.username);
this.setState({
targetUsername: this.state.username,
isCalling: true
});
},
err => {
console.log(`startCallUsers fail ${JSON.stringify(err)}`);
}
);

}, () => {
console.log('initEngine ' + JSON.stringify(res))
});
}

componentDidMount() {
// JMRTCViewController.addCallOutgoingListener()

JMRTCViewController.releaseEngine()
JMRTCViewController.initEngine( (res) => {
console.log('initEngine ' + JSON.stringify(res))
}, () => {
console.log('initEngine ' + JSON.stringify(res))
});

JMRTCViewController.addCallReceiveInviteListener((inviteArr) => {
console.log('addCallReceiveInviteListener' + JSON.stringify(inviteArr));
this.setState({targetUsername: inviteArr.joinedMembers[0].username});
this.setState({isBeCalling: true})
})

// JMRTCViewController.addCallConnectingListener(callback)

JMRTCViewController.addCallConnectedListener(() =>{
JMRTCViewController.setVideoView({ username: "0001" });
console.log('addCallConnectedListener');
setTimeout(() => {
JMRTCViewController.setVideoView({ username: this.props.myUsername });
}, 1000);

})

JMRTCViewController.addCallMemberJoinListener(() => {
JMRTCViewController.setVideoView({ username: "0002" });
JMRTCViewController.addCallMemberJoinListener((map) => {
console.log('addCallMemberJoinListener ' + JSON.stringify(map));
JMRTCViewController.setVideoView({ username: map.username });
});

// JMRTCViewController.addCallDisconnectListener(callback)
JMRTCViewController.addCallDisconnectListener(() => {
console.log('addCallDisconnectListener ');
this.setState({isCalling: false, isBeCalling: false})
})

JMRTCViewController.addCallMemberLeaveListener( () => {
JMRTCViewController.hangup(() => {
this.setState({isCalling: false})
this.setState({isCalling: false, isBeCalling: false})

}, () => {
this.setState({ isCalling: false });
this.setState({ isCalling: false ,isBeCalling: false});
Alert.alert('hangup', 'error')
})

Expand All @@ -71,11 +110,7 @@ export default class RTCComponent extends Component {
// JMRTCViewController.addCallErrorListener(callback)

// JMRTCViewController.addCallUserVideoStreamEnabledListener(callback)
JMRTCViewController.initEngine( (res) => {
console.log(JSON.stringify(res))
}, () => {

});

}

render() {
Expand Down Expand Up @@ -110,9 +145,11 @@ export default class RTCComponent extends Component {
JMRTCViewController.switchCamera()
} }
onClickMute={ () => {
JMRTCViewController.isMuted((res) => {
JMRTCViewController.setIsMuted({muted: !res})
})
// JMRTCViewController.isMuted((res) => {
console.log("muted:" + this.isMuted);
this.isMuted = !this.isMuted;
JMRTCViewController.setIsMuted({muted: this.isMuted})
// })
} }
onClickHangoff={ () => {
JMRTCViewController.hangup(() => {
Expand All @@ -131,33 +168,21 @@ export default class RTCComponent extends Component {
<FormButton
title="视频"
onPress={ () => {
JMRTCViewController.startCallUsers(
{ usernames: [this.state.username], type: "video" },
res => {
JMRTCViewController.setVideoView({ username: "0001" });
JMRTCViewController.setVideoView({ username: "0002" });
console.log("targetUsername" + this.props.myUsername);
this.setState({
targetUsername: this.state.username,
isCalling: true
});
},
err => {
console.log(`startCallUsers fail ${JSON.stringify(err)}`);
}
);

this.startCallUser()
} }
/>

<FormButton
title="音频"
onPress={ () => {
JMRTCViewController.startCallUsers({usernames: [this.state.username], type: 'voice'}, (res) => {
console.log(`startCallUsers success ${JSON.stringify(res)}`)
}, (err) => {
console.log(`startCallUsers success ${JSON.stringify(err)}`)
})
this.setState({
isCalling: true
});
// JMRTCViewController.startCallUsers({usernames: [this.state.username], type: 'voice'}, (res) => {
// console.log(`startCallUsers success ${JSON.stringify(res)}`)
// }, (err) => {
// console.log(`startCallUsers success ${JSON.stringify(err)}`)
// })
} }
/>
</View>
Expand Down
Loading

0 comments on commit c591777

Please sign in to comment.