void FFriendsMessageManager::SendGameInviteRequest() { TSharedPtr<FUniqueNetId> UserId = OnlineSubMcp->GetIdentityInterface()->GetUniquePlayerId(0); if ( GameInvitesToSend[ 0 ]->IsValid() ) { FOnlineMessagePayload InvitePayload; TArray<TSharedRef<FUniqueNetId> > Recipients; Recipients.Add( GameInvitesToSend[0] ); InvitePayload.SetAttribute( TEXT("SenderID"), FVariantData( DisplayName ) ); InvitePayload.SetAttribute( TEXT("GameInvite"), FVariantData( UserId.Get()->ToString() ) ); OnlineSubMcp->GetMessageInterface()->SendMessage( 0, Recipients, TEXT("GameInvite"), InvitePayload ); } GameInvitesToSend.RemoveAt( 0 ); }
void FFriendsMessageManager::SendChatMessageRequest() { TSharedPtr<FUniqueNetId> UserId = OnlineSubMcp->GetIdentityInterface()->GetUniquePlayerId(0); if ( ChatMessagesToSend.Num() > 0 ) { FString DisplayMessage = DisplayName; DisplayMessage += TEXT ( " says:\n" ); DisplayMessage += ChatMessagesToSend[0].Message.ToString(); ChatMessages.Add( MakeShareable ( new FFriendsAndChatMessage( DisplayMessage ) ) ); FOnlineMessagePayload TestPayload; TArray<TSharedRef<FUniqueNetId> > Recipients; Recipients.Add( ChatMessagesToSend[0].FriendID ); TestPayload.SetAttribute(TEXT("STRINGValue"), FVariantData( ChatMessagesToSend[0].Message.ToString() ) ); TestPayload.SetAttribute(TEXT("SenderID"), FVariantData( DisplayName ) ); OnlineSubMcp->GetMessageInterface()->SendMessage(0, Recipients, TEXT("TestType"), TestPayload); } ChatMessagesToSend.RemoveAt( 0 ); }
void AMessageSubsystemTestActor::LoginCallback(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error) { UE_LOG(LogTemp, Log, TEXT("%s"), (_identity->GetLoginStatus(0) == ELoginStatus::LoggedIn) ? TEXT("true") : TEXT("false")); TArray<TSharedRef<const FUniqueNetId>> ids; ids.Add(UserId.AsShared()); FOnlineMessagePayload payload = FOnlineMessagePayload(); FVariantData data = FVariantData(); data.SetValue(true); payload.SetAttribute("test", data); _message->SendMessage(0, ids, TEXT("testMessage"), payload); }