- Documentation
- Small Classes
- Sample Codes
- Android
This sample source code contains the sample source code of GoClass Client and GoClass Server. This article describes how to run the sample source code. It is recommended that the client and server be used together. The guidelines are divided into two parts:
- Guidelines for running the sample source code of the GoClass client.
- Guidelines for running the example source code of GoClass server (Golang).
The sample code is for reference only when the developer accesses it. ZEGO is not responsible for the follow-up maintenance of the sample source code.
If the developer plans to use the sample source code in a production environment, please make sure to perform sufficient testing before release to avoid potential problems and losses.
1 GoClass Client Sample Code Operation Guidelines
1.1 Prepare the Environment
Please ensure that the development environment meets the following technical requirements (the following instructions are based on MacOS development computers as examples):
- Android Studio 3.0 or above.
- Android SDK 28 and Android SDK Platform-Tools 28 have been downloaded.
- Android devices or emulators with an Android version of at least 5.0 and support audio and video (recommended to use a real device), if it is a real device, please enable the "Allow debugging" option.
- The Android device is connected to the Internet.
1.2 Prerequisites
Please go to ZEGO Management Console to register an account and apply for the AppID and Server required to initialize the SDK. For the application process, please refer to Project Management.
1.3 Run Sample Code
Find the Android Studio software icon on the development computer.
Open the
Android Studio
software, and clickOpen an existing project
.Select the sample source code that has been downloaded at the beginning of this document and open it. The screenshot here takes GoClass demo as an example.
- The downloaded sample source code lacks relevant SDK packages, which need to be downloaded through the following link, and after decompression, put the relevant files into the app/libs directory of the project.
- Collaborative Whiteboard SDK
- File Sharing SDK
- Express-Video SDK (Please download the version that includes the whiteboard function)
- The downloaded sample code lacks APP_ID and APP_SIGN required for SDK initialization, so the
AuthConstants.java
file needs to be modified. Please use the AppID and AppSign obtained in the "Prerequisites" of this article to fill in correctly (You need to add L after AppID), otherwise the sample source code will not work properly.
At the same time, the host address of the locally deployed GoClass server needs to be configured in the corresponding field of BackendApiConstants.java.
Then you can configure the test environment and other switches in ZegoSDKManager.java.
Select a real Android device (recommended) or emulator that is connected to the Internet. When the device has successfully turned on the developer mode and USB debugging function, you can see the Android Studio as shown below:
Change to the following figure:
It shows that the Android Studio software has successfully connected to the Android device, and the sample source code can be run on the device.
Click the build and run button on the Android Studio software to compile and run the sample source code. If there is a problem during the operation, please contact the instant technical support engineer.
2 GoClass Server (Golang) Sample Code Operation Guidelines
2.1 Environmental Preparation
- Golang 1.11 or above has been installed (recommended 1.13 or above).
- Execute
go env -w GO111MODULE=on
to turn on the golang module. - Execute
go env -w GOPROXY=https://goproxy.cn
to set up golang proxy.
- Redis 2.6 or above has been installed.
2.2 Prerequisites
Please go to ZEGO Management Console to register an account and apply for AppID and ServerSecret. Refer to Project Management.
2.3 Run Sample Code
- Download the GoClass source code.
git clone https://github.com/zegoim/go-class.git
The GoClass sample source code contains the GoClass client source code and server source code. If the developer has downloaded the sample source code package when running the GoClass client source code, there is no need to download it again here.
- Enter the configuration directory
src/go_class_server/go_class_room/conf/
.
cd src/go_class_server/go_class_room/conf/
- Modify the relevant configuration items in the
app.conf
file.
RedisAddr = "192.168.100.62:6379" # redis host
RedisPassword = "" # redis password
RedisIndex = 8 # redis database
[SmallClass] # Small class class appid related configuration If you don’t need small class scene, you don’t need to care about related configuration
AppId = 123456789
AppSecret = "eb2280544902dc1b7ab1fde3985bd083" # ServerSecret obtained from zego console
...
MaxPeopleNum = 10 # The maximum number of people online at the same time in the classroom
MaxJoinLiveNum = 4 # The maximum number of simultaneous microphones in the small class classroom
[LargeClass] # Large class class appid related configuration If you don’t need large class scenario, you don’t need to care about related configuration
AppId = 987654321
AppSecret = "13nce767a02dc1b7bd083ab1fde3985" # ServerSecret obtained from zego console
...
MaxPeopleNum = 50 # Maximum number of simultaneous online people in large classes
MaxJoinLiveNum = 1 # The maximum number of simultaneous microphones in the large class classroom
- Enter the
go_class_room
directory and start the service.
cd ../go_class_room
go run main.go