Files
UnrealEngineUWP/Engine/Plugins/Developer/Concert/ConcertMain/Source/ConcertServer/Private/ConcertServerSession.h
jason walter bfe09fb7c7 Add a multi-user custom event sequencing. The package event and transaction events exists independently from each other but transaction events can occur between packages events. We need to make sure that these are sequenced properly otherwise the transaction could get applied incorrectly.
We also fixed ReplayTransaction when loading an asset; replay transactions only need to occur if the transaction was applied after the package event.

#jira UE-177465
#rb dominik.peacock
#preflight 646f871250786bb5ba85b1ef

[CL 25623286 by jason walter in ue5-main branch]
2023-05-25 12:32:57 -04:00

168 lines
5.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "ConcertSession.h"
#include "ConcertMessages.h"
#include "Containers/Ticker.h"
class IConcertLocalEndpoint;
struct FConcertServerSettings;
/** Implementation of a Concert Server session */
class FConcertServerSession
: public IConcertServerSession
, public TSharedFromThis<FConcertServerSession>
, private FConcertSessionCommonImpl
{
public:
FConcertServerSession(const FConcertSessionInfo& InSessionInfo, const FConcertServerSettings& InSettings, TSharedPtr<IConcertLocalEndpoint> InServerSessionEndpoint, const FString& InSessionDirectory);
virtual ~FConcertServerSession();
virtual void Startup() override;
virtual void Shutdown() override;
virtual const FGuid& GetId() const override
{
return CommonGetId();
}
virtual const FString& GetName() const override
{
return CommonGetName();
}
virtual void SetName(const FString& NewName) override
{
CommonSetName(NewName);
SendSessionNameChanged();
}
virtual FMessageAddress GetClientAddress(const FGuid& ClientEndpointId) const override
{
return ServerSessionEndpoint->GetRemoteAddress(ClientEndpointId);
}
void SetLastModifiedToNow()
{
SessionInfo.SetLastModifiedToNow();
}
virtual const FConcertSessionInfo& GetSessionInfo() const override
{
return CommonGetSessionInfo();
}
virtual TArray<FGuid> GetSessionClientEndpointIds() const override
{
return CommonGetSessionClientEndpointIds();
}
virtual TArray<FConcertSessionClientInfo> GetSessionClients() const override
{
return CommonGetSessionClients();
}
virtual bool FindSessionClient(const FGuid& EndpointId, FConcertSessionClientInfo& OutSessionClientInfo) const override
{
return CommonFindSessionClient(EndpointId, OutSessionClientInfo);
}
virtual FConcertScratchpadRef GetScratchpad() const override
{
return CommonGetScratchpad();
}
virtual FConcertScratchpadPtr GetClientScratchpad(const FGuid& ClientEndpointId) const override
{
return CommonGetClientScratchpad(ClientEndpointId);
}
virtual FOnConcertServerSessionTick& OnTick() override;
virtual FOnConcertServerSessionClientChanged& OnSessionClientChanged() override;
virtual FOnConcertMessageAcknowledgementReceivedFromLocalEndpoint& OnConcertMessageAcknowledgementReceived() override;
virtual FString GetSessionWorkingDirectory() const override;
protected:
virtual FDelegateHandle InternalRegisterCustomEventHandler(const FName& EventMessageType, const TSharedRef<IConcertSessionCustomEventHandler>& Handler) override
{
return CommonRegisterCustomEventHandler(EventMessageType, Handler);
}
virtual void InternalUnregisterCustomEventHandler(const FName& EventMessageType, const FDelegateHandle EventHandle) override
{
CommonUnregisterCustomEventHandler(EventMessageType, EventHandle);
}
virtual void InternalUnregisterCustomEventHandler(const FName& EventMessageType, const void* EventHandler) override
{
CommonUnregisterCustomEventHandler(EventMessageType, EventHandler);
}
virtual void InternalClearCustomEventHandler(const FName& EventMessageType) override
{
CommonClearCustomEventHandler(EventMessageType);
}
virtual void InternalSendCustomEvent(const UScriptStruct* EventType, const void* EventData, const TArray<FGuid>& DestinationEndpointIds, EConcertMessageFlags Flags, TOptional<FConcertSequencedCustomEvent> InSequencedId = {}) override;
virtual void InternalRegisterCustomRequestHandler(const FName& RequestMessageType, const TSharedRef<IConcertSessionCustomRequestHandler>& Handler) override
{
CommonRegisterCustomRequestHandler(RequestMessageType, Handler);
}
virtual void InternalUnregisterCustomRequestHandler(const FName& RequestMessageType) override
{
CommonUnregisterCustomRequestHandler(RequestMessageType);
}
virtual void InternalSendCustomRequest(const UScriptStruct* RequestType, const void* RequestData, const FGuid& DestinationEndpointId, const TSharedRef<IConcertSessionCustomResponseHandler>& Handler) override;
private:
/** */
void HandleRemoteConnectionChanged(const FConcertEndpointContext& RemoteEndpointContext, EConcertRemoteEndpointConnection Connection);
/** */
void HandleDiscoverAndJoinSessionEvent(const FConcertMessageContext& Context);
/** */
void HandleLeaveSessionEvent(const FConcertMessageContext& Context);
/** */
void HandleUpdateClientInfoEvent(const FConcertMessageContext& Context);
/** */
void HandleCustomEvent(const FConcertMessageContext& Context);
/** */
TFuture<FConcertSession_CustomResponse> HandleCustomRequest(const FConcertMessageContext& Context);
/** */
void SendClientListUpdatedEvent();
/** */
void SendSessionNameChanged();
/** */
void TickConnections(float DeltaSeconds);
/** This session endpoint where message are sent and received from. */
IConcertLocalEndpointPtr ServerSessionEndpoint;
/** Ticker for the session */
FTSTicker::FDelegateHandle SessionTick;
/** Callback for when a server session ticks */
FOnConcertServerSessionTick OnTickDelegate;
/** Callback for when a session client state changes */
FOnConcertServerSessionClientChanged OnSessionClientChangedDelegate;
/** The timespan at which session updates are processed. */
const FTimespan SessionTickFrequency;
/** The directory where this session will store its files */
const FString SessionDirectory;
};