GoClass
  • Platform
  • Framework / Engine
  • iOS
  • Android
  • macOS
  • Windows
  • Linux
  • Web
  • WeChat Mini Program
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 Source Code Operation Guidelines

1.1 Prepare the Environment

Please ensure that the development environment meets the following technical requirements:

  • Xcode 7.0 or above.
  • iOS 9.0 or above and an iOS device or simulator that supports audio and video (recommended to use a real device).
  • The iOS 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 AppSign required to initialize the SDK. For the application process, please refer to Project Management.

1.3 Run Sample Code

  1. Open the AppStore, search for Xcode, download and install it.

/Pics/iOS/GoClass/appstore-xcode.png

  1. Use Xcode to open go_class.xcworkspace.

a. Open Xcode and select File> Open... in the upper left corner.

/Pics/iOS/GoClass/xcode-open-file.png

b. Select src/go_class_ios/go_class.xcworkspace in the unzipped sample source code folder, and click Open.

/Pics/iOS/GoClass/open-workspace.png

  1. Log in to your Apple ID account.

a. Open Xcode and select Xcode > Preference in the upper left corner.

b. Click the Account tab, click the + sign in the lower left corner, select to add an Apple ID, and click Continue.

/Pics/iOS/GoClass/xcode-account.png

c. Enter Apple ID and password to log in.

/Pics/iOS/GoClass/xcode-login-apple-id.png

  1. Modify the developer certificate and Bundle Identifier.

a. Open Xcode and click the go_class project on the left.

/Pics/iOS/GoClass/xcode-select-project.png

b. Click the Signing & Capabilities tab and select your own developer certificate in Team.

/Pics/iOS/GoClass/sign-capabilities.png

  1. The downloaded sample source code lacks AppID and AppSign required for SDK initialization, so you need to modify the ZegoAuthConstants.h file. Please use the AppID and AppSign obtained in the "Prerequisites" of this article to fill in correctly otherwise the sample source code will not work properly.

/Pics/iOS/GoClass/appID-AppSign_en.png

At the same time, you need to configure the host address of the locally deployed GOClass server in the corresponding field.

/Pics/iOS/GoClass/app-env-host_en.png

Then you can set the default environment by calling the setNormalEnv method of the ZegoClassEnvManager singleton in the demo, or you can modify it to the developer's target environment in this method.

/Pics/iOS/GoClass/app-env_en.png

  1. Connect the iOS device to the development computer and click Generic iOS Device in the upper left corner of Xcode to select the real iOS device.

/Pics/iOS/GoClass/run-device.png

/Pics/iOS/GoClass/run-chouse-device_en.png

  1. Click the Build button in the upper left corner of Xcode to compile and run the sample source code.

/Pics/iOS/GoClass/run-start_en.png

2 GoClass Server (Golang) Sample Source 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 # The maximum number of simultaneous microphones in the large class classroom
  1. Enter the go_class_room directory and start the service.
cd ../go_class_room
go run main.go