You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
See SESSION console command for details. Some more updates are needed in Automation, Profiler, etc. to perform authorization on a per-instance instead of per-session basis. #CodeReview: peter.sauerbrei [CL 2698089 by Max Preussner in Main branch]
136 lines
3.4 KiB
C++
136 lines
3.4 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SessionServicesPrivatePCH.h"
|
|
#include "ISessionServicesModule.h"
|
|
#include "ModuleManager.h"
|
|
|
|
|
|
/**
|
|
* Implements the SessionServices module.
|
|
*
|
|
* @todo gmp: needs better error handling in case MessageBusPtr is invalid
|
|
*/
|
|
class FSessionServicesModule
|
|
: public FSelfRegisteringExec
|
|
, public ISessionServicesModule
|
|
{
|
|
public:
|
|
|
|
/** Default constructor. */
|
|
FSessionServicesModule()
|
|
: SessionManager(nullptr)
|
|
, SessionService(nullptr)
|
|
{ }
|
|
|
|
public:
|
|
|
|
// FSelfRegisteringExec interface
|
|
|
|
virtual bool Exec(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) override
|
|
{
|
|
if (!FParse::Command(&Cmd, TEXT("SESSION")))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (FParse::Command(&Cmd, TEXT("AUTH")))
|
|
{
|
|
FApp::AuthorizeUser(FParse::Token(Cmd, false));
|
|
}
|
|
else if (FParse::Command(&Cmd, TEXT("DENY")))
|
|
{
|
|
FApp::DenyUser(FParse::Token(Cmd, false));
|
|
}
|
|
else if (FParse::Command(&Cmd, TEXT("DENYALL")))
|
|
{
|
|
FApp::DenyAllUsers();
|
|
}
|
|
else if (FParse::Command(&Cmd, TEXT("STATUS")))
|
|
{
|
|
Ar.Logf(TEXT("Instance ID: %s"), *FApp::GetInstanceId().ToString());
|
|
Ar.Logf(TEXT("Instance Name: %s"), *FApp::GetInstanceName());
|
|
Ar.Logf(TEXT("Session ID: %s"), *FApp::GetSessionId().ToString());
|
|
Ar.Logf(TEXT("Session Name: %s"), *FApp::GetSessionName());
|
|
Ar.Logf(TEXT("Session Owner: %s"), *FApp::GetSessionOwner());
|
|
Ar.Logf(TEXT("Standalone: %s"), FApp::IsStandalone() ? *GYes.ToString() : *GNo.ToString());
|
|
}
|
|
else if (FParse::Command(&Cmd, TEXT("SETNAME")))
|
|
{
|
|
FApp::SetSessionName(FParse::Token(Cmd, false));
|
|
}
|
|
else if (FParse::Command(&Cmd, TEXT("SETOWNER")))
|
|
{
|
|
FApp::SetSessionOwner(FParse::Token(Cmd, false));
|
|
}
|
|
else
|
|
{
|
|
// show usage
|
|
Ar.Log(TEXT("Usage: SESSION <Command>"));
|
|
Ar.Log(TEXT(""));
|
|
Ar.Log(TEXT("Command"));
|
|
Ar.Log(TEXT(" AUTH <UserName> = Authorize a user to interact with this instance"));
|
|
Ar.Log(TEXT(" DENY <UserName> = Unauthorize a user from interacting with this instance"));
|
|
Ar.Log(TEXT(" DENYALL = Removes all authorized session users"));
|
|
Ar.Log(TEXT(" SETNAME <Name> = Sets the name of this instance"));
|
|
Ar.Log(TEXT(" SETOWNER <Owner> = Sets the name of the owner of this instance"));
|
|
Ar.Log(TEXT(" STATUS = Displays the status of this application session"));
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public:
|
|
|
|
// ISessionServicesModule interface
|
|
|
|
virtual ISessionManagerRef GetSessionManager() override
|
|
{
|
|
if (!SessionManager.IsValid())
|
|
{
|
|
SessionManager = MakeShareable(new FSessionManager(MessageBusPtr.Pin().ToSharedRef()));
|
|
}
|
|
|
|
return SessionManager.ToSharedRef();
|
|
}
|
|
|
|
virtual ISessionServiceRef GetSessionService() override
|
|
{
|
|
if (!SessionService.IsValid())
|
|
{
|
|
SessionService = MakeShareable(new FSessionService(MessageBusPtr.Pin().ToSharedRef()));
|
|
}
|
|
|
|
return SessionService.ToSharedRef();
|
|
}
|
|
|
|
public:
|
|
|
|
// IModuleInterface interface
|
|
|
|
virtual void StartupModule() override
|
|
{
|
|
MessageBusPtr = IMessagingModule::Get().GetDefaultBus();
|
|
check(MessageBusPtr.IsValid());
|
|
}
|
|
|
|
virtual void ShutdownModule() override
|
|
{
|
|
SessionManager.Reset();
|
|
SessionService.Reset();
|
|
}
|
|
|
|
private:
|
|
|
|
/** Holds a weak pointer to the message bus. */
|
|
IMessageBusWeakPtr MessageBusPtr;
|
|
|
|
/** Holds the session manager singleton. */
|
|
ISessionManagerPtr SessionManager;
|
|
|
|
/** Holds the session service singleton. */
|
|
ISessionServicePtr SessionService;
|
|
};
|
|
|
|
|
|
IMPLEMENT_MODULE(FSessionServicesModule, SessionServices);
|