AppId and Key in advance. For more information on how to apply for GME services, see Activating Services. appId is the AppID and authKey is the permission key in the console. 
UserConfig.cpp in the Source\\UEDemo1 path, and change the appID and appKey in the red box as shown below to the AppID and permission key applied for in Service Management > Application Settings in the GME console.


openID, which is the unique identifier of a user in the application. The openID value must be unique on each terminal.

RoomID for room entry and the local openID.3D Voice Effect is selected on both terminals, use the A, S, D, and W keys to move around and experience the directional 3D stereo effect.

Init > EnterRoom > EnableMic > EnableSpeaker. The main code of the sample project is in BaseViewController.cpp and ExperientialDemoViewController.cpp.InitGME function in the BaseViewController.cpp file. It includes initialization, authentication initialization for voice message, and TMGDelegate callback settings.int UBaseViewController::InitGME(std::string sdkAppId, std::string sdkAppKey, std::string userId) {int nAppid = atoi(sdkAppId.c_str());int ret = ITMGContextGetInstance()->Init(sdkAppId.c_str(), userId.c_str());ITMGContextGetInstance()->SetTMGDelegate(this);int RetCode = (int) ITMGContextGetInstance()->CheckMicPermission();FString msg = FString::Printf(TEXT("check Permission retcode =%d"), RetCode);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, *msg);char strSig[128] = {0};unsigned int nLength = 128;nLength = QAVSDK_AuthBuffer_GenAuthBuffer(nAppid, "0", userId.c_str(), sdkAppKey.c_str(), (unsigned char *)strSig, nLength);ITMGContextGetInstance()->GetPTT()->ApplyPTTAuthbuffer(strSig, nLength);m_appId = sdkAppId;m_appKey = sdkAppKey;m_userId = userId;m_isEnableTips = false;m_tipsMark = 0;return ret;}
Poll function in Tick in the UEDemoLevelScriptActor.cpp script.void AUEDemoLevelScriptActor::Tick(float DeltaSeconds) {Super::Tick(DeltaSeconds);m_pTestDemoViewController->UpdateTips();m_pCurrentViewController->UpdatePosition();ITMGContextGetInstance()->Poll();}
EnterRoom function in the BaseViewController.cpp file.void UBaseViewController::EnterRoom(std::string roomID, ITMG_ROOM_TYPE roomType) {int nAppid = atoi(m_appId.c_str());UserConfig::SetRoomID(roomID);char strSig[128] = {0};unsigned int nLength = 128;nLength = QAVSDK_AuthBuffer_GenAuthBuffer(nAppid, roomID.c_str(), m_userId.c_str(), m_appKey.c_str(), (unsigned char *)strSig, nLength);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, TEXT("onEnterRoom"));ITMGContextGetInstance()->EnterRoom(roomID.c_str(), roomType, strSig, nLength);}
OnEvent function in the same script.if (eventType == ITMG_MAIN_EVENT_TYPE_ENTER_ROOM) {int32 result = JsonObject->GetIntegerField(TEXT("result"));FString error_info = JsonObject->GetStringField(TEXT("error_info"));if (result == 0) {GEngine->AddOnScreenDebugMessage(INDEX_NONE, 20.0f, FColor::Yellow, TEXT("Enter room success."));}else {FString msg = FString::Printf(TEXT("Enter room failed. result=%d, info = %ls"), result, *error_info);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 20.0f, FColor::Yellow, *msg);}onEnterRoomCompleted(result, error_info);
ExperientialDemoViewController.cpp.void UExperientialDemoViewController::onCheckMic(bool isChecked) {//GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, L"onCheckMic");ITMGContext *pContext = ITMGContextGetInstance();if (pContext) {ITMGAudioCtrl *pTmgCtrl = pContext->GetAudioCtrl();if (pTmgCtrl) {pTmgCtrl->EnableMic(isChecked);}}}void UExperientialDemoViewController::onCheckSpeaker(bool isChecked) {//GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, L"onCheckSpeaker");ITMGContext *pContext = ITMGContextGetInstance();if (pContext) {ITMGAudioCtrl *pTmgCtrl = pContext->GetAudioCtrl();if (pTmgCtrl) {pTmgCtrl->EnableSpeaker(isChecked);}}}
ExperientialDemoViewController.cpp.void UExperientialDemoViewController::onCheckSpatializer(bool isChecked) {char buffer[256]={0};// snprintf(buffer, sizeof(buffer), "%s3d_model", getFilePath().c_str());snprintf(buffer, sizeof(buffer), "%sgme_2.8_3d_model.dat", getFilePath().c_str());int ret1 = ITMGContextGetInstance()->GetAudioCtrl()->InitSpatializer(buffer);int ret2 = ITMGContextGetInstance()->GetAudioCtrl()->EnableSpatializer(isChecked, false);FString msg = FString::Printf(TEXT("InitSpatializer=%d, EnableSpatializer ret=%d"), ret1, ret2);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, msg);}
UpdatePosition function in Tick in the UEDemoLevelScriptActor.cpp script .void AUEDemoLevelScriptActor::Tick(float DeltaSeconds) {Super::Tick(DeltaSeconds);m_pTestDemoViewController->UpdateTips();m_pCurrentViewController->UpdatePosition();ITMGContextGetInstance()->Poll();}void UBaseViewController::UpdatePosition() {if (!m_isCreated)return;ITMGRoom *pTmgRoom = ITMGContextGetInstance()->GetRoom();if (!pTmgRoom){return;}int nRange = GetRange();pTmgRoom->UpdateAudioRecvRange(nRange);FVector cameraLocation = UGameplayStatics::GetPlayerCameraManager(m_pActor->GetWorld(), 0)->GetCameraLocation();FRotator cameraRotation = UGameplayStatics::GetPlayerCameraManager(m_pActor->GetWorld(), 0)->GetCameraRotation();FString msg = FString::Printf(TEXT("location(x=%.2f,y=%.2f,z=%.2f), rotation(pitch=%.2f,yaw=%.2f,roll=%.2f)"),cameraLocation.X, cameraLocation.Y, cameraLocation.Z, cameraRotation.Pitch, cameraRotation.Yaw, cameraRotation.Roll);int position[] = { (int)cameraLocation.X,(int)cameraLocation.Y, (int)cameraLocation.Z };FMatrix matrix = ((FRotationMatrix)cameraRotation);float forward[] = { matrix.GetColumn(0).X,matrix.GetColumn(1).X,matrix.GetColumn(2).X };float right[] = { matrix.GetColumn(0).Y,matrix.GetColumn(1).Y,matrix.GetColumn(2).Y };float up[] = { matrix.GetColumn(0).Z,matrix.GetColumn(1).Z,matrix.GetColumn(2).Z };pTmgRoom->UpdateSelfPosition(position, forward, right, up);SetPositionInfo(msg);}
ExperientialDemoViewController.cpp.void UExperientialDemoViewController::onCheckSpatializer(bool isChecked) {char buffer[256]={0};// snprintf(buffer, sizeof(buffer), "%s3d_model", getFilePath().c_str());snprintf(buffer, sizeof(buffer), "%sgme_2.8_3d_model.dat", getFilePath().c_str());int ret1 = ITMGContextGetInstance()->GetAudioCtrl()->InitSpatializer(buffer);int ret2 = ITMGContextGetInstance()->GetAudioCtrl()->EnableSpatializer(isChecked, false);FString msg = FString::Printf(TEXT("InitSpatializer=%d, EnableSpatializer ret=%d"), ret1, ret2);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, msg);}
Feedback