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

Use non-legacy service methods (and some refactoring of messages/packets handling) #1036

Merged
merged 8 commits into from
Nov 14, 2021
Merged

Conversation

xPaw
Copy link
Member

@xPaw xPaw commented Oct 9, 2021

Ref: #909

This appears to work, but the implementation is questionable at best. I haven't tested ServiceMethodSendToClient.

GetDeserializedResponse could be removed if responses were handled similarly to how they're done for notifications here: https://github.com/xPaw/SteamKit/blob/c3964e89564575083dfd30c354394ec13131301c/SteamKit2/SteamKit2/Steam/Handlers/SteamUnifiedMessages/SteamUnifiedMessages.cs#L182

However, it will not work if consumers have their own protobufs that SK doesn't have.

SteamKit2/SteamKit2/Base/ClientMsg.cs Outdated Show resolved Hide resolved
@@ -50,13 +50,13 @@ public string RpcName
public string MethodName { get; private set; }


internal ServiceMethodResponse( JobID jobID, EResult result, CMsgClientServiceMethodLegacyResponse resp )
internal ServiceMethodResponse( JobID jobID, EResult result, ClientMsgProtobuf response, IPacketMsg packetMsg )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pass in just the target job name rather than the whole proto message object, considering that all we do with it is immediately dot into the target job name?

Alternatively, why deserialise it to get to the target job name, when PacketClientMsgProtobuf (IPacketMsg subclass) has already deserialised the proto header? We shouldn't need to deserialise it twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it does. Then why does ClientMsgProtobuf also deserialize the header?

{
var response = new ClientMsgProtobuf<CMsgClientServiceMethodLegacyResponse>( packetMsg );
var callback = new ServiceMethodResponse(response.TargetJobID, (EResult)response.ProtoHeader.eresult, response.Body);
var response = new ClientMsgProtobuf( packetMsg );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above re. deserialising the message twice - the IPacketMsg object here should already contain what we need.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to contain the raw payload, which would mean I'd still have to skip over the header when deserializing the body.

@yaakov-h yaakov-h linked an issue Oct 10, 2021 that may be closed by this pull request
@xPaw xPaw changed the title Use non-legacy service methods Use non-legacy service methods (and some refactoring of messages/packets handling) Oct 10, 2021
@xPaw
Copy link
Member Author

xPaw commented Oct 18, 2021

FYI you mentioned #266, but that issue talks about GC messages which this PR doesn't touch.

@yaakov-h
Copy link
Member

Right, I meant the same concept (since all those message types are very similar) - being able to construct a message by giving it a body, rather than having the message allocate the body and then having to manipulate its properties through the Body getter.

@yaakov-h yaakov-h mentioned this pull request Nov 13, 2021
13 tasks
Copy link
Member

@yaakov-h yaakov-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that service methods and service notifications are working with this.

Not sure I like making the header object public though, see comments on that. Perhaps they should be internal.

SteamKit2/SteamKit2/Base/PacketBase.cs Outdated Show resolved Hide resolved
SteamKit2/SteamKit2/Base/ClientMsg.cs Outdated Show resolved Hide resolved
SteamKit2/SteamKit2/Base/PacketBase.cs Outdated Show resolved Hide resolved
SteamKit2/SteamKit2/Base/PacketBase.cs Outdated Show resolved Hide resolved
SteamKit2/SteamKit2/Base/ClientMsg.cs Outdated Show resolved Hide resolved
@yaakov-h yaakov-h merged commit 9811319 into SteamRE:master Nov 14, 2021
@xPaw xPaw deleted the servicemethod branch November 14, 2021 11:57
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

Successfully merging this pull request may close these issues.

Use new service method emsg
3 participants