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
- 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.
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.
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
Switch to the directory where the project is located in Terminal and execute
npm installcommand to install dependencies.
yarn run electron:serveor
npm run electron:servecommand in the Terminal to run the sample source code, and the login window will pop up automatically after running successfully.
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).
go env -w GO111MODULE=onto turn on the golang module.
go env -w GOPROXY=https://goproxy.cnto set up golang proxy.
- Redis 2.6 or above has been installed.
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
- Modify the relevant configuration items in the
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
- Enter the
go_class_roomdirectory and start the service.
cd ../go_class_room go run main.go