public BotContact(byte[] nick_data, byte[] public_key, int role_index, bool has_avatar, bool send_notification = true, BotContactStatus status = BotContactStatus.normal) { setNick(nick_data); publicKey = public_key; setRole(role_index); hasAvatar = has_avatar; sendNotification = send_notification; this.status = status; }
public BotContact(byte[] contact_bytes, bool nick_as_string) { using (MemoryStream m = new MemoryStream(contact_bytes)) { using (BinaryReader reader = new BinaryReader(m)) { if (nick_as_string) { nick = reader.ReadString(); } else { int nd_length = reader.ReadInt32(); if (nd_length > 0) { setNick(reader.ReadBytes(nd_length)); } } int pk_length = reader.ReadInt32(); if (pk_length > 0) { publicKey = reader.ReadBytes(pk_length); } // TODO try/catch wrapper can be removed after upgrade try { if (m.Position < m.Length) { role = reader.ReadString(); hasAvatar = reader.ReadBoolean(); sendNotification = reader.ReadBoolean(); status = (BotContactStatus)reader.ReadInt16(); } }catch (Exception) { } } } }