Commit a79a4dca authored by Geovanny Vera's avatar Geovanny Vera

Meeting Screen Share and permissions

parent 34cf84d5
...@@ -12,4 +12,5 @@ Saved ...@@ -12,4 +12,5 @@ Saved
*.sln *.sln
*.suo *.suo
*.xcodeproj *.xcodeproj
*.xcworkspace *.xcworkspace
\ No newline at end of file .env
\ No newline at end of file
...@@ -34,9 +34,9 @@ ThreePlayerSplitscreenLayout=FavorTop ...@@ -34,9 +34,9 @@ ThreePlayerSplitscreenLayout=FavorTop
FourPlayerSplitscreenLayout=Grid FourPlayerSplitscreenLayout=Grid
bOffsetPlayerGamepadIds=False bOffsetPlayerGamepadIds=False
GameInstanceClass=/Script/VRClassroom.VRCGameInstance GameInstanceClass=/Script/VRClassroom.VRCGameInstance
GameDefaultMap=/Game/Campus/Maps/Login.Login GameDefaultMap=/Game/Campus/Maps/MainMenu.MainMenu
ServerDefaultMap=/Game/Campus/Maps/TestServer.TestServer ServerDefaultMap=/Game/Campus/Maps/TestServer.TestServer
GlobalDefaultGameMode=/Game/Campus/Blueprints/BP_CGameMode.BP_CGameMode_C GlobalDefaultGameMode=/Game/Campus/Blueprints/GM_CGameMode.GM_CGameMode_C
GlobalDefaultServerGameMode=None GlobalDefaultServerGameMode=None
[/Script/AndroidRuntimeSettings.AndroidRuntimeSettings] [/Script/AndroidRuntimeSettings.AndroidRuntimeSettings]
......
...@@ -131,7 +131,6 @@ DoubleClickTime=0.200000 ...@@ -131,7 +131,6 @@ DoubleClickTime=0.200000
+ActionMappings=(ActionName="TeleportRight",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Daydream_Right_Trackpad_Click) +ActionMappings=(ActionName="TeleportRight",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Daydream_Right_Trackpad_Click)
+ActionMappings=(ActionName="TeleportRight",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Right_A_Click) +ActionMappings=(ActionName="TeleportRight",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Right_A_Click)
+ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Vive_Left_Trackpad_Click) +ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Vive_Left_Trackpad_Click)
+ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Left_Thumbstick_Click)
+ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=ValveIndex_Left_Thumbstick_Click) +ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=ValveIndex_Left_Thumbstick_Click)
+ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MixedReality_Left_Thumbstick_Click) +ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MixedReality_Left_Thumbstick_Click)
+ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusGo_Left_Trackpad_Click) +ActionMappings=(ActionName="TeleportLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusGo_Left_Trackpad_Click)
...@@ -166,44 +165,8 @@ DoubleClickTime=0.200000 ...@@ -166,44 +165,8 @@ DoubleClickTime=0.200000
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Right_Trigger) +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Right_Trigger)
+ActionMappings=(ActionName="ToggleKeyboard",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Right_B_Click) +ActionMappings=(ActionName="ToggleKeyboard",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Right_B_Click)
+ActionMappings=(ActionName="ToggleMenu",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Left_Menu_Click) +ActionMappings=(ActionName="ToggleMenu",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Left_Menu_Click)
+ActionMappings=(ActionName="UseAbility3",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Three)
+ActionMappings=(ActionName="UseAbility4",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Four)
+ActionMappings=(ActionName="UseAbility5",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Five)
+ActionMappings=(ActionName="UseAbility6",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Six)
+ActionMappings=(ActionName="UseAbility7",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Seven)
+ActionMappings=(ActionName="UseAbility8",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Eight)
+ActionMappings=(ActionName="UseAbility9",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Nine)
+ActionMappings=(ActionName="CancelInput",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
+ActionMappings=(ActionName="LoadNewItem",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F)
+ActionMappings=(ActionName="ToggleCursorMode",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Tab)
+ActionMappings=(ActionName="ConfirmInput",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton) +ActionMappings=(ActionName="ConfirmInput",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton)
+ActionMappings=(ActionName="UseAbility0",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Zero) +ActionMappings=(ActionName="ShowUsers",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Left_Thumbstick_Click)
+ActionMappings=(ActionName="UseAbility3",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftShift)
+ActionMappings=(ActionName="UseWeapon1",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton)
+ActionMappings=(ActionName="ToggleInventory",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=I)
+ActionMappings=(ActionName="UseAbility11",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F1)
+ActionMappings=(ActionName="UseAbility12",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F2)
+ActionMappings=(ActionName="UseAbility13",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F3)
+ActionMappings=(ActionName="UseAbility14",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F4)
+ActionMappings=(ActionName="UseAbility15",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F5)
+ActionMappings=(ActionName="UseAbility16",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F6)
+ActionMappings=(ActionName="UseAbility17",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F7)
+ActionMappings=(ActionName="UseAbility18",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F8)
+ActionMappings=(ActionName="UseAbility19",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F9)
+ActionMappings=(ActionName="UseAbility20",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F10)
+ActionMappings=(ActionName="UseAbility21",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F11)
+ActionMappings=(ActionName="UseAbility22",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=F12)
+ActionMappings=(ActionName="Dodge",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftControl)
+ActionMappings=(ActionName="Dodge",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Right)
+ActionMappings=(ActionName="ShowPlayersOnline",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=O)
+ActionMappings=(ActionName="ShowItemLibrary",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=L)
+ActionMappings=(ActionName="ShowRunningZones",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Z)
+ActionMappings=(ActionName="FocusToChat",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Slash)
+ActionMappings=(ActionName="ShowPartyWidget",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=P)
+ActionMappings=(ActionName="ShowCharacterSheet",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=C)
+ActionMappings=(ActionName="ClearTarget",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=BackSpace)
+ActionMappings=(ActionName="SelectTargetOrPressSwitch",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton)
+ActionMappings=(ActionName="TeleportOutOfDungeon",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=T)
+AxisMappings=(AxisName="TeleportDirectionUp",Scale=1.000000,Key=Gamepad_LeftY) +AxisMappings=(AxisName="TeleportDirectionUp",Scale=1.000000,Key=Gamepad_LeftY)
+AxisMappings=(AxisName="TeleportDirectionRight",Scale=1.000000,Key=Gamepad_LeftX) +AxisMappings=(AxisName="TeleportDirectionRight",Scale=1.000000,Key=Gamepad_LeftX)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=Vive_Left_Trackpad_Y) +AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=Vive_Left_Trackpad_Y)
......
...@@ -215,6 +215,11 @@ ...@@ -215,6 +215,11 @@
"dns-packet": "^5.1.2" "dns-packet": "^5.1.2"
} }
}, },
"dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
},
"duplexer3": { "duplexer3": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz",
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"name": "world-server-client", "name": "world-server-client",
"dependencies": { "dependencies": {
"@koa/router": "^8.0.8", "@koa/router": "^8.0.8",
"dotenv": "^8.2.0",
"koa": "^2.11.0", "koa": "^2.11.0",
"koa-body": "^4.1.1", "koa-body": "^4.1.1",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
......
const Router = require('@koa/router'); const Router = require('@koa/router');
const CONFIG = require('./config.js'); const CONFIG = require('./config.js');
const {spawn} = require('child_process'); const {spawn} = require('child_process');
require('dotenv/config')
const router = new Router(); const router = new Router();
const ServerUser = process.env.SERVER_USERNAME;
const ServerPasswd = process.env.SERVER_PASSWD;
router.post('/', (ctx, next) => { router.post('/', (ctx, next) => {
const body = ctx.request.body; const body = ctx.request.body;
console.log(`Server ${body.name}`); console.log(`Server ${body.name}`);
const sub = spawn(CONFIG.UE4_PATH, [CONFIG.PROJECT_PATH, `${body.name}?listen?ip=${CONFIG.ip}?port=${body.port}`, '-server', '-log', '-nosteam', '-messaging', `-port=${body.port}`], { const sub = spawn(CONFIG.UE4_PATH, [CONFIG.PROJECT_PATH, `${body.name}?listen?ip=${CONFIG.ip}?port=${body.port}?serverUserName=${ServerUser}?serverPasswd=${ServerPasswd}`, '-server', '-log', '-nosteam', '-messaging', `-port=${body.port}`], {
detached: true, detached: true,
stdio: 'ignore' stdio: 'ignore'
}); });
...@@ -19,8 +23,8 @@ router.post('/', (ctx, next) => { ...@@ -19,8 +23,8 @@ router.post('/', (ctx, next) => {
router.post('/meeting', (ctx, next) => { router.post('/meeting', (ctx, next) => {
const body = ctx.request.body; const body = ctx.request.body;
console.log(`Classroom ${body.name}`); console.log(`Classroom ${body.name} Id: ${body.meetingId}`);
const sub = spawn(CONFIG.UE4_PATH, [CONFIG.PROJECT_PATH, `${body.name}?listen?ip=${CONFIG.ip}?port=${body.port}`, '-server', '-log', '-nosteam', '-messaging', `-port=${body.port}`], { const sub = spawn(CONFIG.UE4_PATH, [CONFIG.PROJECT_PATH, `${body.name}?listen?ip=${CONFIG.ip}?port=${body.port}?serverUserName=${ServerUser}?serverPasswd=${ServerPasswd}?meetingId=${body.meetingId}`, '-server', '-log', '-nosteam', '-messaging', `-port=${body.port}`], {
detached: true, detached: true,
stdio: 'ignore' stdio: 'ignore'
}); });
......
...@@ -147,26 +147,35 @@ bool FVlc::Initialize() ...@@ -147,26 +147,35 @@ bool FVlc::Initialize()
#elif PLATFORM_MAC #elif PLATFORM_MAC
const FString LibDir = FPaths::Combine(*VlcDir, TEXT("Mac")); const FString LibDir = FPaths::Combine(*VlcDir, TEXT("Mac"));
#elif PLATFORM_WINDOWS #elif PLATFORM_WINDOWS
UE_LOG(LogVlcMedia, Warning, TEXT("On Windows"));
#if PLATFORM_64BITS #if PLATFORM_64BITS
const FString LibDir = FPaths::Combine(*VlcDir, TEXT("Win64")); const FString LibDir = FPaths::Combine(*VlcDir, TEXT("Win64"));
#else #else
const FString LibDir = FPaths::Combine(*VlcDir, TEXT("Win32")); const FString LibDir = FPaths::Combine(*VlcDir, TEXT("Win32"));
#endif #endif
#elif PLATFORM_ANDROID
UE_LOG(LogVlcMedia, Warning, TEXT("Start Import"));
const FString LibDir = FPaths::Combine(*VlcDir, TEXT("Android"));
#endif #endif
UE_LOG(LogVlcMedia, Warning, TEXT("Start Import"));
// load required libraries in the correct order // load required libraries in the correct order
#if !PLATFORM_ANDROID
if (!LoadDependency(LibDir, TEXT("libvlccore"), CoreHandle)) if (!LoadDependency(LibDir, TEXT("libvlccore"), CoreHandle))
{ {
UE_LOG(LogVlcMedia, Warning, TEXT("No Core"));
return false; return false;
} }
#endif
UE_LOG(LogVlcMedia, Warning, TEXT("After Core"));
if (!LoadDependency(LibDir, TEXT("libvlc"), LibHandle)) if (!LoadDependency(LibDir, TEXT("libvlc"), LibHandle))
{ {
UE_LOG(LogVlcMedia, Warning, TEXT("No lib"));
FreeDependency(CoreHandle); FreeDependency(CoreHandle);
return false; return false;
} }
UE_LOG(LogVlcMedia, Warning, TEXT("After lib"));
PluginDir = FPaths::ConvertRelativePathToFull(FPaths::Combine(*LibDir, TEXT("plugins"))); PluginDir = FPaths::ConvertRelativePathToFull(FPaths::Combine(*LibDir, TEXT("plugins")));
#if PLATFORM_LINUX #if PLATFORM_LINUX
...@@ -261,7 +270,9 @@ bool FVlc::Initialize() ...@@ -261,7 +270,9 @@ bool FVlc::Initialize()
VLC_IMPORT(libvlc_track_description_release, TrackDescriptionListRelease) VLC_IMPORT(libvlc_track_description_release, TrackDescriptionListRelease)
// import core functions // import core functions
#if !PLATFORM_ANDROID
VLCCORE_IMPORT(vlc_fourcc_GetChromaDescription, FourccGetChromaDescription) VLCCORE_IMPORT(vlc_fourcc_GetChromaDescription, FourccGetChromaDescription)
#endif
return true; return true;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"CreatedBy" : "Epic Games Inc", "CreatedBy" : "Epic Games Inc",
"CreatedByURL" : "http://epicgames.com", "CreatedByURL" : "http://epicgames.com",
"DocsURL" : "https://github.com/ue4plugins/VlcMedia", "DocsURL" : "https://github.com/ue4plugins/VlcMedia",
"EngineVersion" : "4.25.0", "EngineVersion" : "4.25.4",
"Description" : "Implements a media player using the Video LAN Codec (libvlc).", "Description" : "Implements a media player using the Video LAN Codec (libvlc).",
"Category" : "Media Players", "Category" : "Media Players",
"EnabledByDefault" : true, "EnabledByDefault" : true,
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
"Name" : "VlcMedia", "Name" : "VlcMedia",
"Type" : "RuntimeNoCommandlet", "Type" : "RuntimeNoCommandlet",
"LoadingPhase" : "PreLoadingScreen", "LoadingPhase" : "PreLoadingScreen",
"WhitelistPlatforms" : [ "Linux", "Mac", "Win32", "Win64" ] "WhitelistPlatforms" : [ "Linux", "Mac", "Win32", "Win64", "Android" ]
}, },
{ {
"Name" : "VlcMediaEditor", "Name" : "VlcMediaEditor",
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
"Name": "VlcMediaFactory", "Name": "VlcMediaFactory",
"Type": "RuntimeNoCommandlet", "Type": "RuntimeNoCommandlet",
"LoadingPhase" : "PostEngineInit", "LoadingPhase" : "PostEngineInit",
"WhitelistPlatforms" : [ "Linux", "Mac", "Win32", "Win64" ] "WhitelistPlatforms" : [ "Linux", "Mac", "Win32", "Win64", "Android" ]
} }
], ],
......
...@@ -14,7 +14,10 @@ UHttpService::UHttpService(const class FObjectInitializer& ObjectInitializer) : ...@@ -14,7 +14,10 @@ UHttpService::UHttpService(const class FObjectInitializer& ObjectInitializer) :
VRCAPIPath, VRCAPIPath,
GGameIni GGameIni
);*/ );*/
VRCAPIPath = FString(TEXT("https://api.ev3.me/")); //VRCAPIPath = FString(TEXT("https://api.ev3.me/"));
UE_LOG(LogTemp, Log, TEXT("Setting PATH"));
VRCAPIPath = FString(TEXT("http://localhost:1337/"));
UE_LOG(LogTemp, Log, TEXT("Path: %s"), *VRCAPIPath);
Http = &FHttpModule::Get(); Http = &FHttpModule::Get();
} }
...@@ -31,19 +34,19 @@ void UHttpService::SetAuthToken(FString token) { ...@@ -31,19 +34,19 @@ void UHttpService::SetAuthToken(FString token) {
else { else {
UE_LOG(LogTemp, Log, TEXT("I don't know anymore")); UE_LOG(LogTemp, Log, TEXT("I don't know anymore"));
} }
FString killme = FString("Bearer "); //TODO: Fix access violation error when changing FString
killme.Append(token);
//AuthToken = FString("Bearer "); //AuthToken = FString(TEXT("Bearer "));
//AuthToken.Append(token);
//AuthToken.Empty(); //AuthToken.Empty();
//AuthToken.Append(*killme);
} }
FString UHttpService::GetAuthToken() { FString UHttpService::GetAuthToken() {
FString why = FString("Bearer "); //FString why = FString("Bearer ");
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance()); //UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
why.Append(GameInstance->GetUserToken()); //why.Append(GameInstance->GetUserToken());
return why; return AuthToken;
} }
void UHttpService::SetTimeout(float Timeout) { void UHttpService::SetTimeout(float Timeout) {
...@@ -74,7 +77,7 @@ TSharedRef<IHttpRequest> UHttpService::RequestWithRoute(FString Subroute) { ...@@ -74,7 +77,7 @@ TSharedRef<IHttpRequest> UHttpService::RequestWithRoute(FString Subroute) {
Http = &FHttpModule::Get(); Http = &FHttpModule::Get();
TSharedRef<IHttpRequest> Request = Http->CreateRequest(); TSharedRef<IHttpRequest> Request = Http->CreateRequest();
FString url = FString(VRCAPIPath1); FString url = VRCAPIPath1;
url.Append(Subroute); url.Append(Subroute);
Request->SetURL(url); Request->SetURL(url);
......
...@@ -3,12 +3,105 @@ ...@@ -3,12 +3,105 @@
#include "VRCGameMode.h" #include "VRCGameMode.h"
#include "HttpService.h" #include "HttpService.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "VRCPlayerState.h"
#include "VRCGameInstance.h" #include "VRCGameInstance.h"
AVRCGameMode::AVRCGameMode() { AVRCGameMode::AVRCGameMode() {
EndTimeout = 10.0f; EndTimeout = 10.0f;
} }
FString AVRCGameMode::InitNewPlayer(APlayerController* NewPlayerController, const FUniqueNetIdRepl& UniqueId, const FString& Options, const FString& Portal)
{
FString retString = Super::InitNewPlayer(NewPlayerController, UniqueId, Options, Portal);
UE_LOG(LogTemp, Warning, TEXT("InitNewPlayer Started"));
FString SUserID = "";
FString SUserName = "";
FString SDisplayName = "";
FString IDData = UGameplayStatics::ParseOption(Options, TEXT("ID"));
if (!IDData.IsEmpty())
{
UE_LOG(LogTemp, Warning, TEXT("Raw options: %s"), *IDData);
FString DecodedIDData = FGenericPlatformHttp::UrlDecode(IDData);
UE_LOG(LogTemp, Warning, TEXT("Decoded options: %s"), *DecodedIDData);
TArray<FString> SplitArray;
DecodedIDData.ParseIntoArray(SplitArray, TEXT("|"), false);
SUserID = SplitArray[0];
SUserName = SplitArray[1];
SDisplayName = SplitArray[2];
UE_LOG(LogTemp, Warning, TEXT("PlayerName: %s"), *SUserName);
}
else {
SUserName = "testy";
}
AVRCPlayerState* NewPlayerState = CastChecked<AVRCPlayerState>(NewPlayerController->PlayerState);
if (!SUserID.IsEmpty() && !SDisplayName.IsEmpty()) {
NewPlayerState->UserID = FCString::Atoi(*SUserID);
NewPlayerState->DisplayName = SDisplayName;
}
else {
NewPlayerState->UserID = 111;
NewPlayerState->DisplayName = "Testy";
}
NewPlayerState->UserName = SUserName;
return retString;
}
void AVRCGameMode::LoginSeverUser(FString UserName, FString Password) {
if (Http == NULL) {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
}
Http->SetTimeout(20.0f); //Set timeout
UE_LOG(LogTemp, Warning, TEXT("User: %s, Pass: %s"), *UserName, *Password);
if (UserName.IsEmpty() || Password.IsEmpty()) {
UE_LOG(LogTemp, Error, TEXT("Server Login Credentials not set correctly"));
return;
}
//Trim whitespace
UserName.TrimStartAndEndInline();
Password.TrimStartAndEndInline();
FString PostParameters = FString(TEXT("username=")) + UserName
+ FString(TEXT("&password=")) + Password;
TSharedRef<IHttpRequest> Request = Http->PostRequest("login", PostParameters);
Request->OnProcessRequestComplete().BindUObject(this, &AVRCGameMode::OnLoginSeverUser);
Request->SetHeader("Content-Type", TEXT("application/x-www-form-urlencoded"));
Request->ProcessRequest();
}
void AVRCGameMode::OnLoginSeverUser(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
FString content = *Response->GetContentAsString();
if (Http->ResponseIsValid(Response, bWasSuccessful))
{
UE_LOG(LogTemp, Warning, TEXT("OnLoginSeverUser Success!"));
NotifyLoginSeverUser(content);
}
else
{
UE_LOG(LogTemp, Error, TEXT("OnLoginSeverUser Error accessing login server!"));
}
}
void AVRCGameMode::ShutDown() { void AVRCGameMode::ShutDown() {
GIsRequestingExit = true; GIsRequestingExit = true;
} }
...@@ -52,4 +145,46 @@ void AVRCGameMode::RemoveHubFromAPI(const FString& IP, const FString& PORT) { ...@@ -52,4 +145,46 @@ void AVRCGameMode::RemoveHubFromAPI(const FString& IP, const FString& PORT) {
void AVRCGameMode::RemoveMeetingFromAPI(const FString& IP, const FString& PORT) { void AVRCGameMode::RemoveMeetingFromAPI(const FString& IP, const FString& PORT) {
RemoveInstanceFromAPI(TEXT("instances/remove-meeting"), IP, PORT); RemoveInstanceFromAPI(TEXT("instances/remove-meeting"), IP, PORT);
}
void AVRCGameMode::GetMeetingData(int32 MeetingId) {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
Http->SetTimeout(EndTimeout);
FString SubRoute = "meetings/";
SubRoute.AppendInt(MeetingId);
TSharedRef<IHttpRequest> Request = Http->GetRequest(SubRoute);
Request->OnProcessRequestComplete().BindUObject(this, &AVRCGameMode::OnGetMeetingData);
Request->SetHeader("Accepts", TEXT("application/json"));
FString auth = "Bearer ";
auth.Append(ServerToken);
Request->SetHeader("Authorization", auth);
Request->SetHeader("Accepts", TEXT("application/json"));
Request->ProcessRequest();
}
void AVRCGameMode::OnGetMeetingData(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
if (Http->ResponseIsValid(Response, bWasSuccessful)) {
TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
if (FJsonSerializer::Deserialize(Reader, JsonObject))
{
FString MeetingName = JsonObject->GetStringField("name");
int CreatorId = JsonObject->GetIntegerField("creator_id");
NotifyGetMeetingData(MeetingName, CreatorId);
}
else {
UE_LOG(LogTemp, Error, TEXT("OnGetMeetingData Server returned no data!"));
}
}
else {
UE_LOG(LogTemp, Error, TEXT("OnGetMeetingData Error getting meeting data!"));
}
} }
\ No newline at end of file
...@@ -19,6 +19,11 @@ void UVRCLoginWidget::LoginAndCreateSession(FString Username, FString Password) ...@@ -19,6 +19,11 @@ void UVRCLoginWidget::LoginAndCreateSession(FString Username, FString Password)
} }
Http->SetTimeout(LoginTimeout); //Set timeout Http->SetTimeout(LoginTimeout); //Set timeout
FString UsernameA = FPlatformMisc::GetEnvironmentVariable(TEXT("UEServerUserName"));
FString PasswordA = FPlatformMisc::GetEnvironmentVariable(TEXT("UEServerPassword"));
UE_LOG(LogTemp, Warning, TEXT("User: %s, Pass: %s"), *UsernameA, *PasswordA);
//Trim whitespace //Trim whitespace
Username.TrimStartAndEndInline(); Username.TrimStartAndEndInline();
Password.TrimStartAndEndInline(); Password.TrimStartAndEndInline();
...@@ -38,7 +43,6 @@ void UVRCLoginWidget::OnLoginAndCreateSessionResponseReceived(FHttpRequestPtr Re ...@@ -38,7 +43,6 @@ void UVRCLoginWidget::OnLoginAndCreateSessionResponseReceived(FHttpRequestPtr Re
FString content = *Response->GetContentAsString(); FString content = *Response->GetContentAsString();
if (Http->ResponseIsValid(Response, bWasSuccessful)) if (Http->ResponseIsValid(Response, bWasSuccessful))
{ {
TSharedPtr<FJsonObject> JsonObject;
NotifyLoginAndCreateSession(content); NotifyLoginAndCreateSession(content);
} }
else else
......
...@@ -15,6 +15,25 @@ void AVRCPlayerController::TravelToMap(const FString& URL, const bool SeamlessTr ...@@ -15,6 +15,25 @@ void AVRCPlayerController::TravelToMap(const FString& URL, const bool SeamlessTr
ClientTravel(URL, TRAVEL_Absolute, false, FGuid()); ClientTravel(URL, TRAVEL_Absolute, false, FGuid());
} }
void AVRCPlayerController::TravelToMapWithState(const FString& URL, const bool SeamlessTravel) {
AVRCPlayerState* state = GetVRCPlayerState();
if (!state) {
UE_LOG(LogTemp, Error, TEXT("Invalid VRC Player State. Can't travel with state"));
return;
}
FString IDData = FString::FromInt(state->UserID)
+ "|" + FGenericPlatformHttp::UrlEncode(state->UserName)
+ "|" + FGenericPlatformHttp::UrlEncode(state->DisplayName);
//TODO: Encrypt IDData with AES
FString NewUrl = URL
+ FString(TEXT("?ID=")) + IDData;
TravelToMap(NewUrl, SeamlessTravel);
}
void AVRCPlayerController::ConnectToHub() { void AVRCPlayerController::ConnectToHub() {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance()); UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
...@@ -48,7 +67,7 @@ void AVRCPlayerController::OnConnectToHubResponseRecieved(FHttpRequestPtr Reques ...@@ -48,7 +67,7 @@ void AVRCPlayerController::OnConnectToHubResponseRecieved(FHttpRequestPtr Reques
FString URL = IP + FString(TEXT(":")) + PORT.Left(4); FString URL = IP + FString(TEXT(":")) + PORT.Left(4);
UE_LOG(LogTemp, Log, TEXT("OnConnectToHub IP is %s Port %s, Both"), *IP, *PORT, *URL); UE_LOG(LogTemp, Log, TEXT("OnConnectToHub IP is %s Port %s, Both"), *IP, *PORT, *URL);
TravelToMap(URL, true); TravelToMapWithState(URL, true);
} }
else { else {
...@@ -83,7 +102,6 @@ void AVRCPlayerController::ConnectToMeeting(int32 MeetingId) { ...@@ -83,7 +102,6 @@ void AVRCPlayerController::ConnectToMeeting(int32 MeetingId) {
} }
void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) { void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
FString content = *Response->GetContentAsString();
if(Http->ResponseIsValid(Response, bWasSuccessful)){ if(Http->ResponseIsValid(Response, bWasSuccessful)){
UE_LOG(LogTemp, Log, TEXT("Connecting to meeting")); UE_LOG(LogTemp, Log, TEXT("Connecting to meeting"));
...@@ -96,9 +114,9 @@ void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Re ...@@ -96,9 +114,9 @@ void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Re
FString PORT = JsonObject->GetStringField("port"); FString PORT = JsonObject->GetStringField("port");
FString URL = IP + FString(TEXT(":")) + PORT.Left(4); FString URL = IP + FString(TEXT(":")) + PORT.Left(4);
UE_LOG(LogTemp, Log, TEXT("OnConnectToMeeting IP is %s Port %s, Both"), *IP, *PORT, *URL); UE_LOG(LogTemp, Log, TEXT("OnConnectToMeeting IP is %s Port %s, Both %s"), *IP, *PORT, *URL);
TravelToMap(URL, true); TravelToMapWithState(URL, true);
} }
else { else {
UE_LOG(LogTemp, Error, TEXT("OnConnectToMeeting Server returned no data!")); UE_LOG(LogTemp, Error, TEXT("OnConnectToMeeting Server returned no data!"));
...@@ -108,3 +126,58 @@ void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Re ...@@ -108,3 +126,58 @@ void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Re
UE_LOG(LogTemp, Error, TEXT("Connect to meeting failed")); UE_LOG(LogTemp, Error, TEXT("Connect to meeting failed"));
} }
} }
void AVRCPlayerController::GetUserData() {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
FString token = GameInstance->GetUserToken();
Http->SetTimeout(20.0f);
TSharedRef<IHttpRequest> Request = Http->GetRequest("users/");
Request->SetHeader("Accepts", TEXT("application/json"));
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnGetUserDataRecieved);
FString auth = "Bearer ";
auth.Append(token);
Request->SetHeader("Authorization", auth);
Request->SetHeader("Accepts", TEXT("application/json"));
Request->ProcessRequest();
}
void AVRCPlayerController::OnGetUserDataRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
if (Http->ResponseIsValid(Response, bWasSuccessful)) {
TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
if (FJsonSerializer::Deserialize(Reader, JsonObject))
{
int UserID = JsonObject->GetIntegerField("id");
FString UserName = JsonObject->GetStringField("username");
FString DisplayName = JsonObject->GetStringField("display_name");
AVRCPlayerState* playerState = GetVRCPlayerState();
playerState->UserID = UserID;
playerState->UserName = UserName;
playerState->DisplayName = DisplayName;
UE_LOG(LogTemp, Log, TEXT("OnGetUserData success"));
}
else {
UE_LOG(LogTemp, Error, TEXT("OnGetUserData Server returned no data!"));
}
}
else {
UE_LOG(LogTemp, Error, TEXT("Get User Failed"));
}
}
AVRCPlayerState* AVRCPlayerController::GetVRCPlayerState() const {
return GetPlayerState<AVRCPlayerState>();
}
// Copyright 2020 Testy
#include "VRCPlayerState.h"
#include "UnrealNetwork.h"
AVRCPlayerState::AVRCPlayerState(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
bReplicates = true;
}
void AVRCPlayerState::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AVRCPlayerState, UserID);
DOREPLIFETIME(AVRCPlayerState, UserName);
DOREPLIFETIME(AVRCPlayerState, DisplayName);
}
\ No newline at end of file
...@@ -15,13 +15,16 @@ class VRCLASSROOM_API UHttpService : public UObject ...@@ -15,13 +15,16 @@ class VRCLASSROOM_API UHttpService : public UObject
GENERATED_BODY() GENERATED_BODY()
FHttpModule* Http; FHttpModule* Http;
FString AuthToken;
public: public:
UHttpService(const class FObjectInitializer& ObjectInitializer); UHttpService(const class FObjectInitializer& ObjectInitializer);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "API")
FString AuthToken;
FString VRCAPIPath = ""; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "API")
FString VRCAPIPath = FString(TEXT("http://localhost:1337/"));
UHttpService* GetHttp(); UHttpService* GetHttp();
......
...@@ -7,6 +7,16 @@ ...@@ -7,6 +7,16 @@
#include "HttpService.h" #include "HttpService.h"
#include "VRCGameMode.generated.h" #include "VRCGameMode.generated.h"
USTRUCT(BlueprintType, Blueprintable)
struct FUserPermissions {
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Permissions")
bool bCanShareScreen;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Permissions")
bool bCanWriteOnBoard;
};
/** /**
* *
*/ */
...@@ -16,10 +26,26 @@ class VRCLASSROOM_API AVRCGameMode : public AGameMode ...@@ -16,10 +26,26 @@ class VRCLASSROOM_API AVRCGameMode : public AGameMode
GENERATED_BODY() GENERATED_BODY()
UHttpService* Http; UHttpService* Http;
protected:
FString InitNewPlayer(APlayerController* NewPlayerController, const FUniqueNetIdRepl& UniqueId, const FString& Options, const FString& Portal);
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "API")
FString ServerToken;
AVRCGameMode(); AVRCGameMode();
UFUNCTION(BlueprintCallable, Category = "API")
void LoginSeverUser(FString UserName, FString Password);
void OnLoginSeverUser(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
UFUNCTION(BlueprintImplementableEvent, Category = "API")
void NotifyLoginSeverUser(const FString& Token);
UFUNCTION(BlueprintCallable, Category = "Engine", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject", Keywords = "Shut Down")) UFUNCTION(BlueprintCallable, Category = "Engine", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject", Keywords = "Shut Down"))
void ShutDown(); void ShutDown();
...@@ -39,5 +65,13 @@ public: ...@@ -39,5 +65,13 @@ public:
UFUNCTION(BlueprintImplementableEvent, Category = "API") UFUNCTION(BlueprintImplementableEvent, Category = "API")
void NotifyRemoveInstanceFromAPI(); void NotifyRemoveInstanceFromAPI();
UFUNCTION(BlueprintCallable, Category = "API")
void GetMeetingData(int32 MeetingId);
void OnGetMeetingData(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
UFUNCTION(BlueprintImplementableEvent, Category = "API")
void NotifyGetMeetingData(const FString& MeetingName, int creatorId);
}; };
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "HttpService.h" #include "HttpService.h"
#include "VRCPlayerState.h"
#include "VRCPlayerController.generated.h" #include "VRCPlayerController.generated.h"
USTRUCT(BlueprintType, Blueprintable) USTRUCT(BlueprintType, Blueprintable)
...@@ -41,6 +42,9 @@ public: ...@@ -41,6 +42,9 @@ public:
UFUNCTION(BlueprintCallable, Category = "Travel") UFUNCTION(BlueprintCallable, Category = "Travel")
void TravelToMap(const FString& URL, const bool SeamlessTravel); void TravelToMap(const FString& URL, const bool SeamlessTravel);
UFUNCTION(BlueprintCallable, Category = "Travel")
void TravelToMapWithState(const FString& URL, const bool SeamlessTravel);
UFUNCTION(BlueprintCallable, Category = "Travel") UFUNCTION(BlueprintCallable, Category = "Travel")
void ConnectToHub(); void ConnectToHub();
...@@ -50,5 +54,12 @@ public: ...@@ -50,5 +54,12 @@ public:
void ConnectToMeeting(int32 MeetingId); void ConnectToMeeting(int32 MeetingId);
void OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful); void OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
UFUNCTION(BlueprintCallable, Category = "User")
void GetUserData();
void OnGetUserDataRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
AVRCPlayerState* GetVRCPlayerState() const;
}; };
// Copyright 2020 Testy
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerState.h"
#include "VRCPlayerState.generated.h"
/**
*
*/
UCLASS()
class VRCLASSROOM_API AVRCPlayerState : public APlayerState
{
GENERATED_BODY()
public:
AVRCPlayerState(const class FObjectInitializer& ObjectInitializer);
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "User", Replicated)
int UserID;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "User", Replicated)
FString UserName;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "User", Replicated)
FString DisplayName;
void GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment