04-13-2018 07:42 AM
04-17-2018 12:29 AM
04-17-2018 05:47 AM
void UMRGameInstance::Init()
{
Super::Init();
IOnlineSubsystem* OnlineSub = Online::GetSubsystem(GetWorld(), OCULUS_SUBSYSTEM);
if (OnlineSub)
{
// This is not safe, but even Epic advises us to do so.
// And sadly we need the OculusSubsystem, not just the Interface
OculusSubsystem = static_cast<FOnlineSubsystemOculus*>(OnlineSub);
// Listen to the RoomGet and RoomInviteReceived delegates.
// Oculus pops messages already on tick, so we have to register to their queue.
if (OculusSubsystem)
{
OnRoomReceivedDelegate_Handle = OculusSubsystem->GetNotifDelegate(ovrMessage_Room_Get).AddUObject(this, &UMRGameInstance::OnRoomReceived);
OnRoomInviteReceivedDelegate_Handle = OculusSubsystem->GetNotifDelegate(ovrMessage_Notification_Room_InviteReceived).AddUObject(this, &UMRGameInstance::OnRoomInviteReceived);
}
}
}
void UMRGameInstance::Shutdown()
{
// Make sure to clean these delegates up again!
if (OnRoomInviteReceivedDelegate_Handle.IsValid() && OculusSubsystem)
{
OculusSubsystem->RemoveNotifDelegate(ovrMessage_Notification_Room_InviteReceived, OnRoomInviteReceivedDelegate_Handle);
OnRoomInviteReceivedDelegate_Handle.Reset();
OculusSubsystem->RemoveNotifDelegate(ovrMessage_Room_Get, OnRoomReceivedDelegate_Handle);
OnRoomReceivedDelegate_Handle.Reset();
}
Super::Shutdown();
}
/** Pointer to the Oculus Subsystem. */
FOnlineSubsystemOculus* OculusSubsystem;
/** Delegate Handle. */
FDelegateHandle OnRoomInviteReceivedDelegate_Handle;
FDelegateHandle OnRoomReceivedDelegate_Handle;
/** Handles the Room Invite Message. */
void OnRoomInviteReceived(ovrMessageHandle Message, bool bIsError);
/** Handles receiving the room itself. */
void OnRoomReceived(ovrMessageHandle Message, bool bIsError);
virtual void Init() override;
virtual void Shutdown() override;
// Retrieve RoomID
ovrRoomInviteNotificationHandle RoomInviteHandle = ovr_Message_GetRoomInviteNotification(Message);
ovrID RoomID = ovr_RoomInviteNotification_GetRoomID(RoomInviteHandle);
// This returns an "ovrRequest" which you can save in an array of pending request.
// When receiving the response in "OnRoomReceived" you could use "ovr_Message_GetRequestID(Message)" to receive an "ovrRequest" again and simple compare them. They are just "uint64_t" variables.
ovr_Room_Get(RoomID)
// Retrieve OwnerID
ovrUserHandle Owner = ovr_Room_GetOwner(RoomHandle);
ovrID OwnerID = ovr_User_GetID(Owner);
// FUniqueNetIdOculus is a child of Epic UniqueNetId
// From here on I search for a FriendSession with this ID and then join that session via the normal JoinSession code
TSharedPtr<const FUniqueNetIdOculus> OculusOwnerID = MakeShareable(new FUniqueNetIdOculus(OwnerID));
03-03-2021 05:30 AM
thanks for the detailed description. I figured out the same thing, luckily I saw you stuff before testing and added the delegate for ovrMessage_Room_Get, because on game startup this is the event I can grab in practice, when previously an invite has been accepted, to join the Room, and the game session afterwards. I have never got result from ovrMessage_Notification_Room_InviteReceived so far...
btw, is it possible to suppress Oculus menu in-game when you get an invite? currently we have to exit the game, accept the invite, that opens the game again... thanks.
03-14-2021 04:00 AM
sorry, ovrMessage_Notification_Room_InviteReceived works too, my debugging into log was wrong....
but I'm still struggling with turning off in-game notifications
05-16-2021 07:10 AM
hello I've been trying for weeks to get two headsets to connect using blueprints and I stumble upon this post and realize that this might be why the join session never sees the right map is that correct? I need to make a custom cpp gameinstance ? is that where the map is pulled from as atm I'm using advancedsessiongameinstance
thank you