bool FSessionService::Start()
{
	IMessageBusPtr MessageBus = MessageBusPtr.Pin();

	if (!MessageBus.IsValid())
	{
		return false;
	}

	// initialize messaging
	MessageEndpoint = FMessageEndpoint::Builder("FSessionService", MessageBus.ToSharedRef())
		.Handling<FSessionServiceLogSubscribe>(this, &FSessionService::HandleSessionLogSubscribeMessage)
		.Handling<FSessionServiceLogUnsubscribe>(this, &FSessionService::HandleSessionLogUnsubscribeMessage)
		.Handling<FSessionServicePing>(this, &FSessionService::HandleSessionPingMessage);

	if (!MessageEndpoint.IsValid())
	{
		return false;
	}

	MessageEndpoint->Subscribe<FSessionServicePing>();
	GLog->AddOutputDevice(this);

	return true;
}
void FSessionInfo::UpdateFromMessage( const FSessionServicePong& Message, const IMessageContextRef& Context )
{
	if (Message.SessionId != SessionId)
	{
		return;
	}

	// update session info
	Standalone = Message.Standalone;
	SessionOwner = Message.SessionOwner;
	SessionName = Message.SessionName;

	// update instance
	TSharedPtr<FSessionInstanceInfo>& Instance = Instances.FindOrAdd(Context->GetSender());

	if (Instance.IsValid())
	{
		Instance->UpdateFromMessage(Message, Context);
	}
	else
	{
		IMessageBusPtr MessageBus = MessageBusPtr.Pin();

		if (MessageBus.IsValid())
		{
			Instance = MakeShareable(new FSessionInstanceInfo(Message.InstanceId, AsShared(), MessageBus.ToSharedRef()));
			Instance->OnLogReceived().AddSP(this, &FSessionInfo::HandleLogReceived);
			Instance->UpdateFromMessage(Message, Context);

			InstanceDiscoveredEvent.Broadcast(AsShared(), Instance.ToSharedRef());
		}
	}

	LastUpdateTime = FDateTime::UtcNow();
}
示例#3
0
	virtual IProfilerClientPtr CreateProfilerClient() override
	{
		IMessageBusPtr MessageBus = MessageBusPtr.Pin();

		if (!MessageBus.IsValid())
		{
			return nullptr;
		}
		
		return MakeShareable(new FProfilerClientManager(MessageBus.ToSharedRef()));
	}
	/**
	* Startup the screen shot manager tools module
	*/
	void StartupModule() override
	{
		IMessageBusPtr MessageBus = IMessagingModule::Get().GetDefaultBus();
		check(MessageBus.IsValid());

		// Create the screen shot manager
		if (!ScreenShotManager.IsValid())
		{
			ScreenShotManager = MakeShareable(new FScreenShotManager(MessageBus.ToSharedRef()));
		}

		UpdateScreenShotData();
	}
FWidgetSnapshotService::FWidgetSnapshotService()
{
	if (FPlatformMisc::SupportsMessaging() && FPlatformProcess::SupportsMultithreading())
	{
		IMessageBusPtr MessageBusPtr = IMessagingModule::Get().GetDefaultBus();

		MessageEndpoint = FMessageEndpoint::Builder("FWidgetSnapshotService", MessageBusPtr.ToSharedRef())
			.ReceivingOnThread(ENamedThreads::GameThread)
			.Handling<FWidgetSnapshotRequest>(this, &FWidgetSnapshotService::HandleWidgetSnapshotRequestMessage)
			.Handling<FWidgetSnapshotResponse>(this, &FWidgetSnapshotService::HandleWidgetSnapshotResponseMessage);

		if (MessageEndpoint.IsValid())
		{
			MessageEndpoint->Subscribe<FWidgetSnapshotRequest>();
		}
	}
}
	/**
	 * Creates a new messaging debugger tab.
	 *
	 * @param SpawnTabArgs - The arguments for the tab to spawn.
	 *
	 * @return The spawned tab.
	 */
	TSharedRef<SDockTab> SpawnMessagingDebuggerTab( const FSpawnTabArgs& SpawnTabArgs )
	{
		const TSharedRef<SDockTab> MajorTab = SNew(SDockTab)
			.TabRole(ETabRole::MajorTab);

		TSharedPtr<SWidget> TabContent;
		IMessageBusPtr MessageBus = IMessagingModule::Get().GetDefaultBus();

		if (MessageBus.IsValid())
		{
			TabContent = SNew(SMessagingDebugger, MajorTab, SpawnTabArgs.GetOwnerWindow(), MessageBus->GetTracer(), Style.ToSharedRef());
		}
		else
		{
			TabContent = SNew(STextBlock)
				.Text(LOCTEXT("MessagingSystemUnavailableError", "Sorry, the Messaging system is not available right now"));
		}

		MajorTab->SetContent(TabContent.ToSharedRef());

		return MajorTab;
	}
示例#7
0
void FSessionManager::HandleSessionPongMessage( const FSessionServicePong& Message, const IMessageContextRef& Context )
{
	if (!Message.SessionId.IsValid())
	{
		return;
	}

	if (Message.Standalone && !IsValidOwner(Message.SessionOwner))
	{
		return;
	}

	IMessageBusPtr MessageBus = MessageBusPtr.Pin();

	if (!MessageBus.IsValid())
	{
		return;
	}

	// update session
	TSharedPtr<FSessionInfo>& Session = Sessions.FindOrAdd(Message.SessionId);

	if (Session.IsValid())
	{
		Session->UpdateFromMessage(Message, Context);
	}
	else
	{
		Session = MakeShareable(new FSessionInfo(Message.SessionId, MessageBus.ToSharedRef()));
		Session->OnInstanceDiscovered().AddSP(this, &FSessionManager::HandleInstanceDiscovered);
		Session->OnLogReceived().AddSP(this, &FSessionManager::HandleLogReceived);
		Session->UpdateFromMessage(Message, Context);

		SessionsUpdatedDelegate.Broadcast();
	}
}