0

I get this error whenever I try to deserialize a protobuf byte array... My code follows:

public void GetFloatValue(ulong sid64, string ilink)
    {
        string param_s = null;
        string param_a = null;
        string param_d = null;
        string param_m = null;
        bool goodlink = false;
        bool isinv = false;
        CallbackManager Manager = new CallbackManager(SteamClient);
        new Callback<SteamGameCoordinator.MessageCallback>(onFloatCallback, Manager);
        var Msg = new ClientGCMsgProtobuf<CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest>((uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest);
        if (ilink.Contains("steam://rungame/730") && ilink.Contains("%20S7656"))
        {
            param_s = ilink.Substring(67, 84 - 67);
            param_a = ilink.Substring(85, 95 - 85);
            param_d = ilink.Substring(96, 115 - 96);
            goodlink = true;
            isinv = true;
        }
        else if (ilink.Contains("steam://rungame/730"))
        {
            param_m = ilink.Substring(67, 85 - 67);
            param_a = ilink.Substring(86, 96 - 86);
            param_d = ilink.Substring(97, 116 - 97);
            goodlink = true;
            isinv = false;
        }
        else
        {
            goodlink = false;
        }

        if (goodlink == false)
        {
            SteamFriends.SendChatMessage(sid64, EChatEntryType.ChatMsg, "Error: Bad Inspect Link");
        }
        else if (goodlink == true)
        {
            if (isinv == true)
            {
                Msg.Body.param_a = Convert.ToUInt64(param_a);
                Msg.Body.param_d = Convert.ToUInt64(param_d);
                Msg.Body.param_s = Convert.ToUInt64(param_s);
            }
            else
            {
                Msg.Body.param_a = Convert.ToUInt64(param_a);
                Msg.Body.param_d = Convert.ToUInt64(param_d);
                Msg.Body.param_m = Convert.ToUInt64(param_m);
            }

            var playGame = new ClientMsgProtobuf<CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = new GameID(730),
            });

            SteamClient.Send(playGame);

            var clientHello = new ClientGCMsgProtobuf<CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);
            SteamGameCoordinator.Send(clientHello, 730);

            SteamGameCoordinator.Send(Msg, 730);

            Manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
        }
    }

    public void onFloatCallback(SteamGameCoordinator.MessageCallback callback)
    {
        byte[] bytes = callback.Message.GetData();
        MemoryStream stream = new MemoryStream(bytes);
        var obj = ProtoBuf.Serializer.Deserialize<CEconItemPreviewDataBlock>(stream);
        Console.WriteLine(obj.origin);
    }

The error in the console includes multiple lines where the error is occurring, a few of them are in the protobuf-net class files, but the first one that actually includes a line of my code is on the line that has var obj = ProtoBuf.Serializer.Deserialize<CEconItemPreviewDataBlock>(stream); the next one is at Manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));

Willem Van
  • 40
  • 1
  • 6
  • Could `stream` possibly be something other than a `CEconItemPreviewDataBlock` (or even empty)? – user812786 Mar 02 '16 at 18:05
  • I don't know how I'd check if it's something else, the callback that it is handling (at least I think it is) is the `CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest` which should return either a `CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse` or a `CEconPreviewDataBlock` and I can't use the first one as a IEnumerable – Willem Van Mar 02 '16 at 21:37
  • It looks to me like `bytes` does not contain a protobuf, for whatever reason. It's hard to say why without knowing more about the context. – Kenton Varda Mar 02 '16 at 23:10

0 Answers0