Peek() public method

public Peek ( ) : int
return int
コード例 #1
0
 /// <summary>
 /// Receives the specified reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <param name="version">The version.</param>
 /// <remarks></remarks>
 protected override void OnReceive(BigEndianStream reader, int version)
 {
     if (reader == null)
         throw new System.ArgumentNullException("reader");
     int i = reader.Peek();//if i == 0 it is the first byte of the Username string(because the length is normally < 255). if it is not 0 it is the protocol version
     if (i != 0)
         ProtocolVersion = reader.ReadByte();
     UserName = reader.ReadString16();
     if (UserName.Contains(";"))
     {
         Host = UserName.Substring(UserName.IndexOf(";", StringComparison.Ordinal) + 1);
         UserName = UserName.Substring(0, UserName.IndexOf(";", StringComparison.Ordinal));
     }
     if (ProtocolVersion >= 32)
     {
         string host = reader.ReadString16();
         int port = reader.ReadInt32();
         Host = host + ":" + port;
     }
 }