Skip to content
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

Need help converting RichPresence data to byte[] #108

Closed
rashonski opened this issue Apr 20, 2015 · 8 comments
Closed

Need help converting RichPresence data to byte[] #108

rashonski opened this issue Apr 20, 2015 · 8 comments

Comments

@rashonski
Copy link

The Body of CMsgClientRichPresenceUpload contains RichPresence data, which seems to be a byte array. If I change the view on the analyzer to Binary Key Values, it looks like a serialized class. I've tried multiple ways to convert my own data into that byte array, but I always get different values.

Example:

bytes: 00525000017374617475730023444F54415F52505F424F54505241435449434500016E756D5F706172616D73003000017761746368696E675F736572766572005B413A313A323130383933353136393A353431325D00017761746368696E675F66726F6D5F736572766572005B413A313A3836343436383939343A353431325D000808
utf8 string: \0RP\0�status\0#DOTA_RP_BOTPRACTICE\0�num_params\00\0�watching_server\0[A:1:2108935169:5412]\0�watching_from_server\0[A:1:864468994:5412]\0��

Neither creating a RP class and serializing nor converting a string to byte array seems to get an identical result.

The RichPresense is used to show friends what you're currently doing (playing/watching etc) inside a game.

@rossengeorgiev
Copy link
Contributor

@psychonic
Copy link
Member

SteamKit already has a method for reading them. However, I don't think that
it currently has a method for writing them.
https://github.com/SteamRE/SteamKit/blob/master/SteamKit2/SteamKit2/Types/KeyValue.cs#L623

On Mon, Apr 20, 2015 at 1:10 PM, Rossen Georgiev notifications@github.com
wrote:

I believe this is binary VDF. Here is a decoder implementation:

https://github.com/seishun/node-steam/blob/master/lib/VDF.js


Reply to this email directly or view it on GitHub
#108 (comment).

@rashonski
Copy link
Author

I've also tried copying the incoming rich presence from a second client, but no callback-manager seems to catch an incoming ClientRichPresenceInfo message. Nethook catches it without a problem. Am I missing a callback or is there a way to see all incoming messages?

@voided
Copy link
Member

voided commented Apr 20, 2015

SteamKit doesn't provide a built-in callback for rich presence, you'd need to implement your own handler for it.

And as @psychonic previously mentioned, we also don't have an implementation for writing out binary KV, only reading.

@rashonski
Copy link
Author

Thanks for the help. I've gotten a callback working and copied the key value into my CMsgClientRichPresentUpload, but unfortunately it doesn't seem to be enough. No clients are receiving the update.

I'm still trying to convert the key values into string or byte[], but there are always some bytes wrong. If I convert "RP�status#DOTA_RP_SPECTATING�num_params0�watching_server[A:1:2280182793:5413]�watching_from_server[A:1:2840994821:5413]��" to hex and back, the text becomes broken. The hex seems to miss only 0's (2 at the start for example).

Edit: even when copying the key value, the bytes seem wrong. Here's the part my code:

void OnRichInfo (SteamFriends.ClientRichPresenceCallback2 callback)
{
var play3 = new ClientGCMsgProtobuf<CMsgClientRichPresenceUpload>((uint)EMsg.ClientRichPresenceUpload);
int count = friends.GetFriendCount();
for (int i = 0; i < count; i++)
{
    play3.Body.steamid_broadcast.Add(friends.GetFriendByIndex(i).ConvertToUInt64());
}
play3.Body.rich_presence_kv = callback.rich_presence[0].rich_presence_kv;
gameCoordinator.Send(play3, APPID);
}

If i compare the hex values of both messages, one start with "0525001" (wrong) and the other one starts with "0052500001".

@voided
Copy link
Member

voided commented Apr 21, 2015

If you're just copying the byte[] directly from another client's rich presence to the upload message's byte[], that should just work. You shouldn't have to convert to string or anything.

That said, I personally don't know how RP uploading works, or whether it needs to be in a specific/different format than what friends of the uploading client receive.

I'd go with using nethook, launching dota, and seeing what the client uploads and how it's doing it.

@Netshroud
Copy link

I'd been meaning to implement binary serialisation for now, and that's done simply in 1f1a183.

As far as I know, each game has it's own Rich Presence definition, so you'll need to NetHook it out of that game.

Note that if your Rich Presence object requires data types beyond just KeyValues Object and String, you won't be able to use KeyValue to build the data you need, since it's currently backed by a string only.

@xPaw
Copy link
Member

xPaw commented Aug 10, 2015

Binary saving is great, but there doesn't appear to get it back without saving to a file? There should be a Save function that returns byte[] (or string for non-binary?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants