Aura.Msgr.Network.Send.ChangeOptionsR C# (CSharp) Method

ChangeOptionsR() public static method

Updates options on the client on success.
public static ChangeOptionsR ( MsgrClient client, bool success ) : void
client MsgrClient
success bool
return void
		public static void ChangeOptionsR(MsgrClient client, bool success)
		{
			var packet = new Packet(Op.Msgr.ChangeOptionsR, 0);

			packet.PutByte(success);
			if (success)
			{
				packet.PutString(client.User.Nickname);
				packet.PutByte((byte)client.User.Status);
				packet.PutUInt((uint)client.User.ChatOptions);
			}

			client.Send(packet);
		}

Usage Example

コード例 #1
0
ファイル: MsgrHandlers.cs プロジェクト: anjhony6778/aura
        public void ChangeOptions(MsgrClient client, Packet packet)
        {
            var nickname    = packet.GetString();
            var status      = (ContactStatus)packet.GetByte();
            var chatOptions = (ChatOptions)packet.GetUInt();

            var user = client.User;

            // Check nickname
            if (nickname.Length > 50)
            {
                Log.Warning("User '{0}' tried to use a nickname that's longer than 50 characters.", user.AccountId);
                Send.ChangeOptionsR(client, false);
                return;
            }

            // Check status
            if (!Enum.IsDefined(typeof(ContactStatus), status))
            {
                Log.Warning("User '{0}' tried to use an invalid or unknown status ({1}).", user.AccountId, status);
                Send.ChangeOptionsR(client, false);
                return;
            }

            // Check options
            if (!Enum.IsDefined(typeof(ChatOptions), chatOptions))
            {
                Log.Warning("User '{0}' tried to use a invalid or unknown options ({1}).", user.AccountId, status);
                Send.ChangeOptionsR(client, false);
                return;
            }

            var prevStatus = user.Status;

            // Change options
            user.Nickname    = nickname;
            user.Status      = status;
            user.ChatOptions = chatOptions;

            MsgrServer.Instance.Database.SaveOptions(user);

            Send.ChangeOptionsR(client, true);

            // Update friends
            var friendUsers = MsgrServer.Instance.UserManager.Get(user.GetNormalFriendIds());

            if (friendUsers.Count == 0)
            {
                return;
            }

            // Set offline if prev was not offline, set online if prev was offline,
            // and just update the options if not offline.
            if (prevStatus != ContactStatus.Offline && status == ContactStatus.Offline)
            {
                Send.FriendOffline(friendUsers, user);
            }
            else if (prevStatus == ContactStatus.Offline && status != ContactStatus.Offline)
            {
                Send.FriendOnline(friendUsers, user);
            }
            else if (status != ContactStatus.Offline)
            {
                Send.FriendOptionChanged(friendUsers, user);
            }
        }