コード例 #1
0
 void PacketFormat(out PlayerExtensionInformation[] playersExtensionInformation, byte[] receivePacketBytes)
 {
     using (MemoryStream stream = new MemoryStream(receivePacketBytes))
     {
         using (BinaryReader reader = new BinaryReader(stream))
         {
             reader.ReadBytes(11);
             int playerCount = reader.ReadInt16();
             playersExtensionInformation = new PlayerExtensionInformation[playerCount];
             for (int i = 0; i < playerCount; i++)
             {
                 int    id           = reader.ReadByte();
                 int    stringLength = reader.ReadByte();
                 string name         = Encoding.Default.GetString(reader.ReadBytes(stringLength));
                 int    score        = reader.ReadInt32();
                 int    ping         = reader.ReadInt32();
                 playersExtensionInformation[i] = new PlayerExtensionInformation(id, name, score, ping);
             }
         }
     }
 }
コード例 #2
0
ファイル: ServerQuery.cs プロジェクト: owwo/trash
 void PacketFormat(out PlayerExtensionInformation[] playersExtensionInformation, byte[] receivePacketBytes)
 {
     using (MemoryStream stream = new MemoryStream(receivePacketBytes))
     {
         using (BinaryReader reader = new BinaryReader(stream))
         {
             reader.ReadBytes(11);
             int playerCount = reader.ReadInt16();
             playersExtensionInformation = new PlayerExtensionInformation[playerCount];
             for (int i = 0; i < playerCount; i++)
             {
                 int id = reader.ReadByte();
                 int stringLength = reader.ReadByte();
                 string name = Encoding.Default.GetString(reader.ReadBytes(stringLength));
                 int score = reader.ReadInt32();
                 int ping = reader.ReadInt32();
                 playersExtensionInformation[i] = new PlayerExtensionInformation(id, name, score, ping);
             }
         }
     }
 }