public MessageData(byte[] data)
        {
            UserInfo = new UserInformation();

            // first 4 bytes show the message type
            UserInfo.MessageType = (MessageType) BitConverter.ToInt32(data, 4);

            //next 4 bytes are for the length of the name
            int nameLength = BitConverter.ToInt32(data, 8);

            // message length
            int messageLength = BitConverter.ToInt32(data, 12);

            UserInfo.Username = nameLength > 0 ? Encoding.ASCII.GetString(data, 16, nameLength) : null;

            UserInfo.Message = messageLength > 0 ? Encoding.ASCII.GetString(data, 16 + nameLength, messageLength) : null;
        }
 public MessageData()
 {
     UserInfo = new UserInformation();
     UserInfo.MessageType = MessageType.Null;
 }