Exemplo n.º 1
0
        public static byte[] CreateMutualContactStatusMessage(int userId)
        {
            UserObj user;

            if (_users.Any(x => x.ID == userId))
            {
                user = _users.Find(x => x.ID == userId);
            }
            else
            {
                user = DatabaseCommunication.ReadUser(userId);
            }

            byte[] dataBytes;

            dataBytes = ByteHelper.ConcatinateArray(BitConverter.GetBytes(user.ID), new byte[] { (byte)((user.Online ? 128 : 0) + 64 + 32 + user.Name.Length) }, Encoding.Unicode.GetBytes(user.Name));

            if (user.Online)
            {
                byte[] socketBytes = ByteHelper.ConcatinateArray(BitConverter.GetBytes(user.Socket.Port), user.Socket.Address.GetAddressBytes());
                dataBytes = ByteHelper.ConcatinateArray(dataBytes, socketBytes);
            }

            return(dataBytes);
        }
Exemplo n.º 2
0
        private void ReadUser_Click(object sender, EventArgs e)
        {
            UserObj user = DatabaseCommunication.ReadUser((int)numericUpDown1.Value);

            if (user != null)
            {
                WriteLog(user.ToString(), Color.Purple.ToArgb());
            }
            else
            {
                WriteLog("user[" + (int)numericUpDown1.Value + "] Does not exist.", Color.Red.ToArgb());
            }
        }
Exemplo n.º 3
0
        public static byte[] CreateNonMutualContactStatusMessage(int userId, bool relationshipTo, bool relationshipFrom)
        {
            UserObj user;

            if (_users.Any(x => x.ID == userId))
            {
                user = _users.Find(x => x.ID == userId);
            }
            else
            {
                user = DatabaseCommunication.ReadUser(userId);
            }

            byte[] dataBytes;

            dataBytes = ByteHelper.ConcatinateArray(BitConverter.GetBytes(user.ID), new byte[] { (byte)((relationshipTo ? 64 : 0) + (relationshipFrom ? 32 : 0) + user.Name.Length) }, Encoding.Unicode.GetBytes(user.Name));

            return(dataBytes);
        }