Documentation
Small_Class Small Classes
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Small Classes
  • Sample Codes
  • Web
Client+Server
Sample Code
GitHub
  • GitHub
Note

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:

  1. Guidelines for running the sample source code of the GoClass client.
  2. 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

  1. Node has been installed.

You can go to node official website to download and refer to nodejs Docs to install.

  1. A browser supported by ZEGO SDK has been installed, as shown in the following table:

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

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 Notes

  • 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
 }

1.4 Run Sample Code

  1. Switch to the directory where the project is located in Terminal and execute yarn install or npm install command to install dependencies.

  2. 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.

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).
  1. Execute go env -w GO111MODULE=on to turn on the golang module.
  2. 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

  1. 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.

  1. Enter the configuration directory src/go_class_server/go_class_room/conf/.
cd src/go_class_server/go_class_room/conf/
  1. 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 # Maximum number of simultaneous microphones in the classroom
  1. Enter the go_class_room directory and start the service.
cd ../go_class_room
go run main.go
Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code