Skip to content

Commit 72d7ae9

Browse files
Sender Side statistics showcase added to Client Observability sample
1 parent 1713d7b commit 72d7ae9

File tree

29 files changed

+960
-0
lines changed

29 files changed

+960
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Build Client-Observability-Java
2+
3+
on:
4+
push:
5+
branches: [main] # Just in case main was not up to date while merging PR
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
run:
11+
continue-on-error: true
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
steps:
16+
- name: checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v1
21+
with:
22+
java-version: 17
23+
24+
- name: Build
25+
run: cd Client-Observability-Java && ./gradlew app:assembleRelease && cd ..
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# intellij
2+
*.iml
3+
4+
.gradle
5+
/local.properties
6+
/.idea/workspace.xml
7+
/.idea/libraries
8+
.DS_Store
9+
/build
10+
/captures
11+
.externalNativeBuild
12+
app/build
13+
14+
.settings/
15+
app/jniLibs/
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Client Observability Java
2+
3+
This application provides a completed version of the OpenTok [Client Observability tutorial](https://tokbox.com/developer/tutorials/android/) for Android (differing only in some additional validation checks). Upon deploying this sample application, you should be able to have two-way audio and video communication using OpenTok.
4+
5+
Main features:
6+
* Connect to an OpenTok session
7+
* Publish an audio-video stream to the session
8+
* Subscribe to another client's audio-video stream
9+
10+
# Configure the app
11+
Open the `OpenTokConfig` file and configure the `API_KEY`, `SESSION_ID`, and `TOKEN` variables. You can obtain these values from your [TokBox account](https://tokbox.com/account/#/).
12+
13+
### (Optional) Deploy a back end web service
14+
15+
For a production application, the `SESSION_ID` and `TOKEN` values must be generated by your app server application and passed to the client, because:
16+
- credentials would expire after a certain amount of time
17+
- credentials are lined to given session (all users would be connected to the same room)
18+
19+
To quickly deploy a pre-built server click at one of the Heroku buttons below. You'll be sent to Heroku's website and prompted for your OpenTok `API Key` and `API Secret` — you can obtain these values on your project page in your [TokBox account](https://tokbox.com/account/user/signup). If you don't have a Heroku account, you'll need to sign up (it's free).
20+
21+
| PHP server | Node.js server|
22+
| ------------- | ------------- |
23+
| <a href="https://heroku.com/deploy?template=https://github.com/opentok/learning-opentok-php" target="_blank"> <img src="https://www.herokucdn.com/deploy/button.png" alt="Deploy"></a> | <a href="https://heroku.com/deploy?template=https://github.com/opentok/learning-opentok-node" target="_blank"> <img src="https://www.herokucdn.com/deploy/button.png" alt="Deploy"></a> |
24+
| [Repository](https://github.com/opentok/learning-opentok-php) | [Repository](https://github.com/opentok/learning-opentok-node) |
25+
26+
> Note: You can also build your server from scratch using one of the [server SDKs](https://tokbox.com/developer/sdks/server/).
27+
28+
After deploying the server open the `ServerConfig` file in this project and configure the `CHAT_SERVER_URL` with your domain to fetch credentials from the server:
29+
30+
```java
31+
public static final String CHAT_SERVER_URL = "https://YOURAPPNAME.herokuapp.com";
32+
```
33+
34+
> Note that this application will ignore credentials in the `OpenTokConfig` file when `CHAT_SERVER_URL` contains a valid URL.
35+
36+
This is the code responsible for retrieving the credentials from web server:
37+
38+
```java
39+
private void getSession() {
40+
Log.i(TAG, "getSession");
41+
42+
Call<GetSessionResponse> call = apiService.getSession();
43+
44+
call.enqueue(new Callback<GetSessionResponse>() {
45+
@Override
46+
public void onResponse(Call<GetSessionResponse> call, Response<GetSessionResponse> response) {
47+
GetSessionResponse body = response.body();
48+
initializeSession(body.apiKey, body.sessionId, body.token);
49+
}
50+
51+
@Override
52+
public void onFailure(Call<GetSessionResponse> call, Throwable t) {
53+
throw new RuntimeException(t.getMessage());
54+
}
55+
});
56+
}
57+
```
58+
59+
## Further Reading
60+
61+
* Review [other sample projects](../)
62+
* Read more about [OpenTok Android SDK](https://tokbox.com/developer/sdks/android/)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/build
2+
config.gradle
3+
*.jar
4+
*.so
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
apply {
6+
from '../../commons.gradle'
7+
}
8+
9+
android {
10+
namespace "com.tokbox.sample.clientobservability"
11+
compileSdkVersion extCompileSdkVersion
12+
13+
defaultConfig {
14+
applicationId "com.tokbox.sample.clientobservability"
15+
minSdkVersion extMinSdkVersion
16+
targetSdkVersion extTargetSdkVersion
17+
versionCode extVersionCode
18+
versionName extVersionName
19+
}
20+
21+
buildTypes {
22+
release {
23+
minifyEnabled extMinifyEnabled
24+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25+
}
26+
}
27+
28+
compileOptions {
29+
sourceCompatibility JavaVersion.VERSION_17
30+
targetCompatibility JavaVersion.VERSION_17
31+
}
32+
}
33+
34+
dependencies {
35+
// Dependency versions are defined in the ../../commons.gradle file
36+
implementation "com.opentok.android:opentok-android-sdk:${extOpentokSdkVersion}"
37+
implementation "androidx.appcompat:appcompat:${extAppCompatVersion}"
38+
implementation "pub.devrel:easypermissions:${extEasyPermissionsVersion}"
39+
implementation "androidx.constraintlayout:constraintlayout:${extConstraintLyoutVersion}"
40+
41+
implementation "com.squareup.retrofit2:retrofit:${extRetrofitVersion}"
42+
implementation "com.squareup.okhttp3:okhttp:${extOkHttpVersion}"
43+
implementation "com.squareup.retrofit2:converter-moshi:${extRetrofit2ConverterMoshi}"
44+
implementation "com.squareup.okhttp3:logging-interceptor:${extOkHttpLoggingInterceptor}"
45+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.tokbox.sample.clientobservability" >
4+
5+
<uses-permission android:name="android.permission.CAMERA" />
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
8+
<uses-permission android:name="android.permission.BLUETOOTH" />
9+
<uses-permission android:name="android.permission.WAKE_LOCK" />
10+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
11+
12+
<uses-feature android:name="android.hardware.camera" />
13+
<uses-feature android:name="android.hardware.camera.autofocus" />
14+
15+
<application
16+
android:allowBackup="true"
17+
android:icon="@mipmap/ic_launcher"
18+
android:label="@string/app_name"
19+
android:theme="@style/AppTheme" >
20+
<activity
21+
android:name=".MainActivity"
22+
android:screenOrientation="portrait"
23+
android:label="@string/app_name"
24+
android:exported="true">
25+
<intent-filter>
26+
<action android:name="android.intent.action.MAIN" />
27+
28+
<category android:name="android.intent.category.LAUNCHER" />
29+
</intent-filter>
30+
</activity>
31+
</application>
32+
33+
</manifest>

0 commit comments

Comments
 (0)