File Sharing
  • iOS
  • Android
  • Web
  • Electron : JavaScript
  • Windows
  • macOS
  • Overview
  • SDK Downloads
  • Demo APP
  • Sample Codes
  • Access Guide
  • Quick Starts
  • Advanced Features
  • Error Codes
  • Server API
  • Documentation
  • File Sharing
  • Sample Codes
Client+Server
Sample Code
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 environment has been installed.
    Platform Remarks
    Windows 32-bit node
    macOS 64-bit node

Please go to node official website to download the software and refer to nodejs Docs to install.

1.2 Prerequisites

Please go to ZEGO Management Console to register an account and apply for the AppID and AppSign 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/.env.development file. Please use the AppID obtained in the "Prerequisites" of this article to fill in correctly.

  • Please refer to Login Room Authentication to obtain the token required to log in to the room in the sample source code, and fill in the interface to obtain the token into the VUE_APP_TOKEN_URL in src/go_class_web/.env.development correctly.

VUE_APP_ZEGO_APPID=Domestic-small class
VUE_APP_ZEGO_APPID2=Overseas-small class

VUE_APP_ZEGO_APPSIGN=
VUE_APP_ZEGO_APPSIGN2=

VUE_APP_TOKEN_URL=YOUR TOKEN_URL
VUE_APP_ELECTRON_SDK=sdk type: express|liveroom; empty, express by default

VUE_APP_CONFIG_TIPS_START=The following is the business domain configuration
VUE_APP_HOME_URL=Domestic official environment address
VUE_APP_OVERSEA_URL=Overseas official environment address
VUE_APP_CONFIG_TIPS_END=The above is the business domain configuration

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 run electron:serve or npm run electron:serve command in the Terminal to run the sample source code, and the login window will pop up automatically after running successfully.

Execute the Control+C command in Terminal to stop the server.

When using the npm run electron:serve command to run the example source code, the electron window may not pop up. Due to network reasons, npm fails to download some resources. Yarn is recommended.

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 classroom
  1. Enter the go_class_room directory and start the service.
cd ../go_class_room
go run main.go
Page Directory