PlayEveryWare / eos_plugin_for_unity

Repository for PlayEveryWare's EOS Plugin for Unity, bringing the functionality of Epic Online Services to the Unity Game Engine.
https://eospluginforunity.playeveryware.com
MIT License
275 stars 52 forks source link

P2P Messages #210

Closed MenesApps closed 1 year ago

MenesApps commented 1 year ago

Probably not a bug, just me being dense, but I have an issue with the P2P Sample. Reading the samples, it seems to only work between Friends. My problem is that my game doesn't use Friends. It simply connects players from a Lobby. I managed to get the Lobby working, Voice is working fine and both players have the other player's id cached.

I added a button to send a dummy message and the plugin says the message is sent on the sender's side, but the other player doesn't get it. Instead he gets this message : LogEOSAuth(Warning): FAccountUtil::GetAsEpicAccount - Epic Account is Empty. Both players are online and connected to the lobby at this point. Where could the issue come from?

Am I doing something wrong or missing something important? Here is my code :

public void TestButton()
    {
        StartCoroutine(SendMessageTest());
    }

    int testmessage = 0;
    IEnumerator SendMessageTest()
    {
        Debug.Log("Sending Message");
        yield return Yielders.Get(.01f);
        testmessage++;
        SendMsg("TestMessage " + testmessage);
    }

    public void SendMsg(string msg)
    {
        Debug.Log("Start Sending");
        messageData message = new messageData();
        message.textData = msg;
        message.type = messageType.textMessage;
        Peer2PeerManager.SendMessage(otherPlayer, message);
    }

Thanks

scovertb commented 1 year ago

Could you reproduce this and post the player logs for the receiving player?

MenesApps commented 1 year ago

Hi @scovertb , thanks for the reply! Sure here is the log by the player that gets the message. Thanks a lot

Log.txt

scovertb commented 1 year ago

What login method was used for the receiving user, and what version of the plugin are you using?

MenesApps commented 1 year ago

What login method was used for the receiving user, and what version of the plugin are you using?

I use the version 2.1.7 from the PackageManager and StartConnectLoginWithDeviceToken on both (the main account is handled by Unity Games Services, EOS is only there for Lobbies, Voice & PvP at the moment). Both of them log in fine, I get their ProductUserIds, they can connect to the Lobby & Voice without issue and get the other ProductUserID when the Lobby is updated for the first time with two players (well before the first message is sent).

It feels like I have missed something somewhere. I am using the sample as an example, but it is using the Friend interface (I don't) so I might have missed a step. Is there a list of the steps required? Thanks

scovertb commented 1 year ago

Logging in with the Connect interface provides a ProductUserId that is not necessarily associated with an Epic account. Accessing all EOS functionality requires logging in with Auth (which provides Account Services functionality like Friends) and Connect (which provides Game Services functionality like Achievements and P2P). The samples are currently set up to login with Auth and then use the received token to also login with Connect, so they haven't been thoroughly tested with just a Connect login. I just logged in to the Achievements sample with Connect using Device Id and immediately received the Epic Account is Empty warning, presumably because there's not an associated Epic account. That said, the P2P interface shouldn't require an Epic account so I'll need to look into it more. It's possible the empty account warnings and the failure to receive the P2P messages are unrelated.

MenesApps commented 1 year ago

Ok. Hopefully this is easily fixable. The PvP mode was available when I was using GameSparks and the players are complaining it got taken away :) Let me know what you find please. Thanks

MenesApps commented 1 year ago

Quick update : Don't know if this helps but the warning only happens for the first message sent. When I click on the message test button, I get a line of log that says the message is sent, then I get the warning 8-10 times in a quick succession. The other player, only gets the warning. But when I click on the button again, I only get the message is sent line on the send, nothing on the receiver and no warning. I also add the P2P code I am using. LobbyRepro.zip

scovertb commented 1 year ago

After modifying the P2P sample I was able to send a message between two users logged in with Connect. Both were using Device ID and the message was received, although I did get the Epic Account is Empty warning multiple times on both ends. Could you also provide the logs for the sending user? I'm assuming you correctly created the Device ID if you were able to log in with it.

MenesApps commented 1 year ago

Yes, the Device ID is created. I manage to login using StartConnectLoginWithDeviceToken. Then I can make, search and join lobbies, use voice without issue. Ok, so if you managed to get it working, it is most definitely a user mistake on my end, probably on the receiving end. I'll check my code again to see if I missed something. Any chance you'd share your modifications so I can compare with mine to see where I went wrong? I understand if not.

Here is the sender's log. SenderLog.txt Thanks a lot. I really appreciate it.

scovertb commented 1 year ago

All I really did was modify the P2P sample scene to be able to send a message to a user via ProductUserId instead of the friends list. Could you update to the latest plugin version and see if the issue persists?

MenesApps commented 1 year ago

Hi. sorry for the delay. I have updated the plugin and the issue is still there. I am going to recheck everything related to P2P to see if I haven't forgotten something.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 7 days with no activity.

MenesApps commented 1 year ago

Bump. The issue is still there. I have yet to find the cause of the problem.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 7 days with no activity.

MenesApps commented 1 year ago

Hi again. Still haven't managed to get it to work, but I found another issue. Not sure if it is related or not. When installed on a completely new device (or after fully uninstalling the app), the StartConnectLoginWithDeviceToken function no longer works. Below is a screenshot of the error. It works on devices that had the app installed before I updated from 2.1.7.

329103814_760464098838899_4212547379411861392_n (1)

scovertb commented 1 year ago

It doesn't appear that StartConnectLoginWithDeviceToken calls connectInterface.CreateDeviceId, which would create those credentials. Uninstalling can remove the device ID but that seems to be platform specific.

MenesApps commented 1 year ago

That was indeed the issue. I didn't have to do that before the update though. Might be an unplanned regression? In any case, it is working now. I didn't find a way to check if the credentials already existed before calling CreateDeviceId so I call CreateDeviceId (with the login function in the callback), add a check to PlayerPrefs when they are created and on the following logins if the PlayerPref key exists, I call StartConnectLoginWithDeviceToken directly instead. Not the cleanest way, but it will be good enough until I get the P2P messages working.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 7 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 7 days since being marked as stale.