public int Deserialize(byte[] ropBytes, int startIndex)
{
int index = startIndex;
this.RopId = ropBytes[index++];
this.InputHandleIndex = ropBytes[index++];
this.ReturnValue = (uint)BitConverter.ToInt32(ropBytes, index);
index += sizeof(uint);
// Only success response has below fields
if (this.ReturnValue == 0)
{
this.IsGhosted = ropBytes[index++];
if (this.IsGhosted != 0)
{
this.ServersCount = BitConverter.ToUInt16(ropBytes, index);
index += sizeof(ushort);
this.CheapServersCount = BitConverter.ToUInt16(ropBytes, index);
index += sizeof(ushort);
if (this.ServersCount > 0)
{
this.Servers = new string[(ushort)this.ServersCount];
for (int i = 0; i < this.ServersCount; i++)
{
int bytesLen = 0;
// Find the string with '\0' end
for (int j = index; j < ropBytes.Length; j++)
{
bytesLen++;
if (ropBytes[j] == 0)
{
break;
}
}
this.Servers[i] = Encoding.ASCII.GetString(ropBytes, index, bytesLen);
index += bytesLen;
}
}
}
}
return index - startIndex;
}
}