public static byte[] WritePublicDirectoryRequest(byte requestType, uint uin, string firstName, string lastName, string nickname, int startBirthyear, int stopBirthyear, string city, Gender gender, bool activeOnly, string familyName, string familyCity, uint start) { using (PacketWriter writer = new PacketWriter()) { writer.Write(requestType); //request type writer.Write((uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); //sequence number if (uin > 0) //uin { writer.Write(Encoding.ASCII.GetBytes("FmNumber")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(uin.ToString())); writer.Write('\0'); } if (firstName != null && firstName != string.Empty) //first name { writer.Write(Encoding.ASCII.GetBytes("firstname")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(firstName)); writer.Write('\0'); } if (lastName != null && lastName != string.Empty) //last name { writer.Write(Encoding.ASCII.GetBytes("lastname")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(lastName)); writer.Write('\0'); } if (nickname != null && nickname != string.Empty) //nickname { writer.Write(Encoding.ASCII.GetBytes("nickname")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(nickname)); writer.Write('\0'); } if (startBirthyear > 0) //birthyear { writer.Write(Encoding.ASCII.GetBytes("birthyear")); writer.Write('\0'); writer.Write(Encoding.ASCII.GetBytes(startBirthyear.ToString())); if (stopBirthyear > 0 && startBirthyear != stopBirthyear) { writer.Write(' '); writer.Write(Encoding.ASCII.GetBytes(stopBirthyear.ToString())); } writer.Write('\0'); } if (city != null || city != string.Empty) //city { writer.Write(Encoding.ASCII.GetBytes("city")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(city)); writer.Write('\0'); } if (gender != Gender.None) //gender { writer.Write(Encoding.ASCII.GetBytes("gender")); writer.Write('\0'); writer.Write(Encoding.ASCII.GetBytes(Utils.ToInternalGender(gender, (requestType != Container.GG_PUBDIR50_SEARCH)).ToString())); writer.Write('\0'); } if (activeOnly) //active { writer.Write(Encoding.ASCII.GetBytes("ActiveOnly")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(Container.GG_PUBDIR50_ACTIVE_TRUE.ToString())); //writer.Write(Encoding.UTF8.GetBytes((activeOnly ? Container.GG_PUBDIR50_ACTIVE_TRUE.ToString() : Container.GG_PUBDIR50_ACTIVE_FALSE.ToString()))); writer.Write('\0'); } if (familyName != null && familyName != string.Empty) //family name { writer.Write(Encoding.ASCII.GetBytes("familyname")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(familyName)); writer.Write('\0'); } if (familyCity != null && familyCity != string.Empty) //family city { writer.Write(Encoding.ASCII.GetBytes("familycity")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(familyCity)); writer.Write('\0'); } if (start > 0) //start uin { writer.Write(Encoding.ASCII.GetBytes("fmstart")); writer.Write('\0'); writer.Write(Encoding.UTF8.GetBytes(start.ToString())); writer.Write('\0'); } return(BuildHeader(Container.GG_PUBDIR50_REQUEST, writer.Data)); } }