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:
You can go to node official website to download and refer to nodejs Docs to install.
Only support SSL web server (https), localhost,127.0.0.1 is equivalent to https.
Platform | Browser/Webview | Remarks |
---|---|---|
Windows | Chrome | Support win7 and above |
macOS | Chrome | Support macOS 10.10 and above |
iOS | Safari | Support iOS 10.0 and above |
iOS | WeChat Embedded Browser | Support iOS 10.0 and above |
Android | Chrome | Support Android 8.0 and above |
Android | WeChat Embedded Browser | Support Android 8.0 and above |
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.
The downloaded sample source code lacks the APP_ID required for SDK initialization, so you need to modify the src/go_class_web/src/utils/config_data.js file. Please use the AppID obtained in the "Prerequisites" of this article to fill in correctly.
In the sample source code, please refer to Room Login Security to obtain the token required to log in to the room, and fill in the interface for obtaining the token correctly in src/go_class_web/src/utils/config_data.js YOUR_SDK_TOKEN_URL.
You need to configure the host address of the locally deployed GoClass server in the corresponding field of src/go_class_web/src/utils/config_data.js. After the background service is deployed successfully, the access address is assumed to be http://127.0.0.1:7779, and the background service address must be filled in as http://127.0.0.1:7779 +'/edu_room'.
Obtaining the camera microphone must be run in the HTTPS environment. Before integrating the SDK, please ensure that the final project can run in the HTTPS environment.
Both the project deployment environment and the background environment need to be consistent.
/**
* YOUR_HOME_SMALL_CLASS_APP_ID: Small class-domestic environment
* YOUR_OVERSEAS_SMALL_CLASS_APP_ID: Small class-overseas environment
* YOUR_HOME_LARGE_CLASS_APP_ID: Large class class-domestic environment
* YOUR_OVERSEAS_LARGE_CLASS_APP_ID: Large class-overseas environment
* YOUR_HOME_SMALL_CLASS_SEVERURL: domestic small class appID corresponding to server address
* YOUR_OVERSEAS_SMALL_CLASS_SEVERURL: overseas small class appID corresponding to server address
* YOUR_HOME_LARGE_CLASS_SEVERURL: The appID of the domestic large class class corresponds to the server address
* YOUR_OVERSEAS_LARGE_CLASS_SEVERURL: The appID of the overseas large class class corresponds to the server address
* YOUR_HOME_BACKEND_URL: Official background business environment-domestic environment
* YOUR_OVERSEAS_BACKEND_URL: Back-office business formal environment-overseas environment
* YOUR_SDK_TOKEN_URL: Get token URL
*/
const YOUR_HOME_SMALL_CLASS_APP_ID = 0
const YOUR_OVERSEAS_SMALL_CLASS_APP_ID = 0
const YOUR_HOME_LARGE_CLASS_APP_ID = 0
const YOUR_OVERSEAS_LARGE_CLASS_APP_ID = 0
const YOUR_HOME_SMALL_CLASS_SEVERURL =''
const YOUR_OVERSEAS_SMALL_CLASS_SEVERURL =''
const YOUR_HOME_LARGE_CLASS_SEVERURL =''
const YOUR_OVERSEAS_LARGE_CLASS_SEVERURL =''
const YOUR_HOME_BACKEND_URL ='' +'/edu_room'
const YOUR_OVERSEAS_BACKEND_URL ='' +'/edu_room'
const YOUR_SDK_TOKEN_URL =''
export {
YOUR_HOME_SMALL_CLASS_APP_ID,
YOUR_OVERSEAS_SMALL_CLASS_APP_ID,
YOUR_HOME_LARGE_CLASS_APP_ID,
YOUR_OVERSEAS_LARGE_CLASS_APP_ID,
YOUR_HOME_SMALL_CLASS_SEVERURL,
YOUR_OVERSEAS_SMALL_CLASS_SEVERURL,
YOUR_HOME_LARGE_CLASS_SEVERURL,
YOUR_OVERSEAS_LARGE_CLASS_SEVERURL,
YOUR_HOME_BACKEND_URL,
YOUR_OVERSEAS_BACKEND_URL,
YOUR_SDK_TOKEN_URL
}
Switch to the directory where the project is located in Terminal and execute yarn install
or npm install
command to install dependencies.
Execute the yarn serve
or npm run serve
command in the Terminal to run the sample source code. After running successfully, access the local server (https://***) in the browser. The example is as follows:
Project is running at https://localhost:8080/
Execute the Control+C
command in Terminal to stop the server.
go env -w GO111MODULE=on
to turn on the golang module.go env -w GOPROXY=https://goproxy.cn
to set up golang proxy.Please go to ZEGO Management Console to register an account and apply for AppID and ServerSecret. Refer to Project Management.
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.
src/go_class_server/go_class_room/conf/
.cd src/go_class_server/go_class_room/conf/
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 # Maximum number of simultaneous microphones in the classroom
go_class_room
directory and start the service.cd ../go_class_room
go run main.go