SteamRE / SteamKit

SteamKit2 is a .NET library designed to interoperate with Valve's Steam network. It aims to provide a simple, yet extensible, interface to perform various actions on the network.
GNU Lesser General Public License v2.1
2.62k stars 497 forks source link

SteamGameCoordinator.MessageCallback not called. #649

Closed TheRdMelon closed 5 years ago

TheRdMelon commented 5 years ago

I'm new, but have spent over 6 hours seeing if I could figure out how this works. I am trying to get detailed information about a CS:GO item, (I'm manually entering the values for testing), as shown here.

I have the following code in a constructor:

SteamClient = new SteamClient();
steamCallbackManager = new CallbackManager(SteamClient);
SteamGameCoordinator = SteamClient.GetHandler<SteamGameCoordinator>();
SteamCallbackManager.Subscribe<SteamGameCoordinator.MessageCallback>(OnGCMessage);
SteamClient.Connect();

and heres the rest:

public void OnGCMessage(SteamGameCoordinator.MessageCallback callback)
{

    Log.Success("Called!");

    if (callback.EMsg == (uint) ECsgoGCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse)
    {

        var response = new ClientGCMsgProtobuf<CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse>((uint) ECsgoGCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse);
        response.Deserialize(callback.Message.GetData());

        Log.Info(Convert.ToString(response.Body.iteminfo.paintwear));

    }

}

requestItemPreviewData()
{
    var requestPreviewData = new ClientGCMsgProtobuf<CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest>((uint) ECsgoGCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest);

    requestPreviewData.Body.param_a = 15690635224;
    requestPreviewData.Body.param_d = 55842557240731818;
    requestPreviewData.Body.param_m = 0;
    requestPreviewData.Body.param_s = 76561198159313411;

    steamGameCoordinator.Send(requestPreviewData, 730);
}

When I call requestItemPreviewData(), I never even see "Called!" in the logs, what am I doing wrong?

yaakov-h commented 5 years ago

Are you actually pumping through the callbacks (example)?

Do you even log in?

TheRdMelon commented 5 years ago

I have added this after SteamClient.Connect();

while (IsRunning)
{

    SteamCallbackManager.RunWaitCallbacks(TimeSpan.FromSeconds(1));

}

I don't know how to log in, is there anywhere I can go to see how exactly to use it without going through examples?

yaakov-h commented 5 years ago

No, that's what the samples are for.

TheRdMelon commented 5 years ago

Ok so I was running off of SteamBot which was probably not the smartest idea for testing, so I wrote out the example you linked me to. Before I go any further trying to implement the CSGO item checking feature, I just want to ask about the OnLoggedOff function, because despite running SteamUser.LogOff(), the OnLoggedOff function is never called, only OnDisconnected. Even after directly coping the example just to make sure (I usually manually copy so I can understand it), it still doesn't call it. So I think the example's broken.

yaakov-h commented 5 years ago

OnLoggedOff is called when Steam sends a logged-off message. This doesn't usually happen when the user requests to be logged off, rather when a user has been signed out because they logged in on another machine (in the old days), or from Steam on the same machine, or possibly for server maintenance.

TheRdMelon commented 5 years ago

Ok thank you, went through the rest of the samples and got it working fine.