Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question SQP / go-svrquery

Discussion in 'Multiplayer' started by Kiwiownage, May 3, 2024.

  1. Kiwiownage

    Kiwiownage

    Joined:
    Mar 26, 2014
    Posts:
    14
    Probably a long shot but we're upgrading from 2019 LTS to 2021 LTS and we're not really having much luck getting the svyquery to correctly read our server_info

    Originally we used this Repo as an example to get us going https://github.com/Unity-Technologies/FPSSample/blob/master/Assets/Scripts/Networking/SQP.cs. But that's now 6 years old

    go-svrquery Repo https://github.com/Unity-Technologies/go-svrquery/tree/master

    It seems the DataStreamWriter/Reader has changed quite a bit. Now strings won't correctly write and while I do get some output it refuses to output server_info

    {
    "version": 0,
    "address": "192.168.1.100:15951"
    }

    Is there any actual examples or documentation for this? Seems pretty barren & we're basically out of ideas at this point besides rewriting the entire backend
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,507
    Could you provide more details please? The code that reads/writes the data and what "won't correctly write" and "refuses to output" actually means eg error messages or actual result.
     
  3. Kiwiownage

    Kiwiownage

    Joined:
    Mar 26, 2014
    Posts:
    14
    Theres no actual error messages i can see in the code. I can't provide the exact code due to NDA reasons sorry but its not much different from the SQP.cs link above. One thing i've noticed is RequestChunks seems to be different each time & its only really "failing" at the QueryResponseHeader (as in it doesn't seem to write ServerInfoData in a way that the svrquery tool can read. I only get Version / address with no server_info output)

    This is from the SQP.cs above & this is I think where the main difference is from 2019 -> 2021. DeferredUShortNetworkByteOrder class no longer exists / WriteString extensions don't seem to actually write to the writer so I've been trying new FixedStringSized writes but not having much luck

    Code (CSharp):
    1.  public void ToStream(ref DataStreamWriter writer)
    2.         {
    3.             var lengthValue = QueryHeader.ToStream(ref writer);
    4.  
    5.             var start = (ushort)writer.Length;
    6.  
    7.             var chunkValue = writer.WriteNetworkByteOrder((uint)0);
    8.  
    9.             var chunkStart = writer.Length;
    10.             ServerInfoData.ToStream(ref writer);
    11.             ChunkLen = (uint)(writer.Length - chunkStart);
    12.             QueryHeader.Length = (ushort)(writer.Length - start);
    13.  
    14.             lengthValue.Update(QueryHeader.Length);
    15.             chunkValue.Update(ChunkLen);
    16.  
    17.             var length = (ushort)System.Net.IPAddress.HostToNetworkOrder((short)QueryHeader.Length);
    18.             var chunkLen = (uint)System.Net.IPAddress.HostToNetworkOrder((int)ChunkLen);
    19.         }
    20.  

    Was really just hoping for some upto date examples or documentation if anything exists. Appreciate the reply
     
  4. Kiwiownage

    Kiwiownage

    Joined:
    Mar 26, 2014
    Posts:
    14
    Ended up just dropping DataStreamWriter/Reader and used byte buffers. Works allgood now
     
    CodeSmile likes this.
  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,507
    Good. I was eyerolling at that code already because of it using StreamWriter/Reader types. ;)