Home > Net >  C # byte problem
C # byte problem

Time:09-20




How to solve, bosses

CodePudding user response:

Your conn. Host and conn. What is the Port

This is because in the value returned from the server, and try to made a mistake by byteReader conversion, specific error in the sentence is don't know, but by additional source QueryConnection class still be able to find where the Fried

And poking fun at the design of the library, is one way to long, prompt information is difficult to locate

With the framework code

 
Public InfoResponse GetInfo ()
{
Try
{
The request (the A2S_INFO_REQUEST);
Var response=fetchResponse ();

Var byteReader=response. GetByteReader ();
Byte header=byteReader. GetByte ();
If (header!=0 x49)
Throw new ArgumentException (" The fetched The Response is no A2S_INFO Response. ");

InfoResponse res=new InfoResponse ();

Res. The Header=Header;
Res. The Protocol=byteReader. GetByte ();
Res. The Name=byteReader. Get string ();
Res. The Map=byteReader. Get string ();
Res. Folder=byteReader. Get string ();
Res. Game=byteReader. Get string ();
Res. ID=byteReader. GetShort ();
Res. Players=byteReader. GetByte ();
Res. MaxPlayers=byteReader. GetByte ();
Res. Bots=byteReader. GetByte ();
Res. The ServerType=byteReader. GetByte () ToServerType ();
Res. The Environment=byteReader. GetByte () ToEnvironment ();
Res. The Visibility=byteReader. GetByte () ToVisibility ();
Res. The VAC=byteReader. GetByte ()==0 x01;
//Check for TheShip
If (res) ID==2400)
{
Res. Mode=byteReader. GetByte () ToTheShipMode ();
Res. Witnesses=byteReader. GetByte ();
Res. Duration=TimeSpan. FromSeconds (byteReader GetByte ());
}
Res., Version=byteReader. Get string ();

//IF from EDF Flag
If (byteReader. Remaining & gt; 0)
{
Res. EDF=byteReader. GetByte ();

If ((res. EDF & amp; 0 x80)==1)
{
Res. The Port=byteReader. GetShort ();
}
If ((res. EDF & amp; 0 x10)==1)
{
Res. SteamID=byteReader. GetLong ();
}
If ((res. EDF & amp; 0 x40)==1)
{
Res. SourceTvPort=byteReader. GetShort ();
Res. SourceTvName=byteReader. Get string ();
}
If ((res. EDF & amp; 0 x20)==1)
{
Res. KeyWords=byteReader. Get string ();
}
If ((res. EDF & amp; 0 x01)==1)
{
Res. GameID=byteReader. GetLong ();
}
}

return res;
}
The catch (Exception ex)
{
Throw new SourceQueryException (" Could not gather Info ", the ex);
}
}

CodePudding user response:

From all of the library code above 16-62 byteReader related logic can be Fried, recommend you get fetchResponse () value, and then see what's his output, should be the value returned will fry here
  •  Tags:  
  • C#
  • Related