-
Notifications
You must be signed in to change notification settings - Fork 1
Update friend presence #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
@judgeaxl How do the external friend ids work? I noticed in the C++ client code that the Is there any way for Drift to know the requesting player's external friend ids? |
The player group was yet another time-to-market "hack" we'd rather forget about. Basically allowing the client to say "here's a group of players I want to treat as a group", and after that there are some endpoints which accept a group name instead of a list of player IDs. Before we had native friends support in drift-base, we relied on external friends, so we'd look up the list of Steam friends a player had, through the Steam API, and then we'd match those against player identities to find Drift IDs for the same players. You'd then get back a list of Drift IDs for any Steam friends who had ever played the game too. Essentially, "hey, I've got these Steam friends, can you check them for me, and call them my_friends?". Sure, the server says, I recognize these two, here's drift-base player info for them. You can refer to them as "my_friends" where you otherwise would send a list of player IDs. I'm not sure how useful this ever was, but it was better than having no way of connecting with other players. |
As for presence, the client is the main "session" record we have. It's reasonable that the Friends API listens to added and removed clients and generates updates for the friends of players. IMO this should use the friendships API rather than player groups, but there's no real constraint other than player groups being a bit of a hack as mentioned above. When querying for client records they have a pseudo property saying if they're online or not, based on the last heartbeat. This obviously lags a bit, if the client crashes, but presence notifications should probably expire rather quickly. Listening for post/delete to clients (via the message bus, as is already done, just not hooked up to anything) would be the place for initiating the notifications when a client is created or deleted. To discover and propagate notifications on clients timing out is harder, unless we add a worker which can go over all clients and message friends of those who have timed out with some interval. |
We should have a general chat about what presence means in terms of many different systems. Is it a notification system between friends only? Are there patterns which would generate an excessive amount of notifications? |
I'm not familiar with the external auth flow in Drift. |
The client asks the local provider, Steam, Game Center or other, for credentials which allow the backend to validate the user, which is usually done either through a JWT validation, or through some API that the backend calls out to. We never trust the client implicitly when it says "Hey, I'm user XYZ on Steam". |
We would like to somehow update the presence of players' friends when they go online/offline.
Initial implementation:
Update online
friends
playergroup which includes all the player idsfriends
playergroup from db that have a registered active, non-heartbeat-timeout clientUpdate offline
friends
playergroup for the exiting playerIssues:
LoadDriftFriends
thefriends
playergroup is created/updated/set and fires the event online event/message againOnFriendsPresenceChanged
delegate by comparing their locally cached state and see if the presence really changed