private void HandleUserProfileRequest(ParseData data)
        {
            DataReader dr          = new DataReader(data.Data);
            int        numAccounts = dr.ReadInt32(); // should always be 1; number of accounts

            if (numAccounts != 1)
            {
                Trace.WriteLine("BN# cannot handle more than one account per user profile request; quitting.");
                BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data);
                return;
            }

            int numKeys   = dr.ReadInt32();
            int requestID = dr.ReadInt32(); // request ID

            string[] keyValues = new string[numKeys];
            for (int i = 0; i < numKeys; i++)
            {
                keyValues[i] = dr.ReadCString(Encoding.UTF8);
            }

            if (m_profileRequests.ContainsKey(requestID))
            {
                UserProfileRequest req = m_profileRequests[requestID];
                int value = 0;
                foreach (UserProfileKey key in req.Keys)
                {
                    req[key] = keyValues[value++];
                }
                m_profileRequests.Remove(requestID);

                UserProfileEventArgs args = new UserProfileEventArgs(req)
                {
                    EventData = data
                };
                OnUserProfileReceived(args);
            }
            else
            {
                Debug.WriteLine(requestID, "Unknown profile request response.");
                BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data);
                return;
            }
        }
Exemple #2
0
 void UserProfileReceived(object sender, UserProfileEventArgs e)
 {
     List<ChatNode> nodesToAdd = new List<ChatNode>() { new ChatNode("User Profile received for ", CssClasses.UserProfileReceivedNotification), new ChatNode(e.Profile.UserName, CssClasses.UsernameOther) };
     foreach (UserProfileKey key in e.Profile)
     {
         nodesToAdd.Add(ChatNode.NewLine);
         nodesToAdd.Add(new ChatNode(string.Concat(key.ToString(), ":"), CssClasses.UserProfileKey));
         if (key.Equals(UserProfileKey.TotalTimeLogged))
         {
             int totalSeconds;
             if (int.TryParse(e.Profile[key], out totalSeconds))
             {
                 TimeSpan ts = TimeSpan.FromSeconds(totalSeconds);
                 nodesToAdd.Add(new ChatNode(string.Format("{0} day{4}, {1} hour{5}, {2} minute{6}, {3} second{7}.",
                     (int)ts.TotalDays, ts.Hours, ts.Minutes, ts.Seconds, ((int)ts.TotalDays == 1) ? string.Empty : "s",
                     ts.Hours == 1 ? string.Empty : "s", ts.Minutes == 1 ? string.Empty : "s", ts.Seconds == 1 ? string.Empty : "s"), CssClasses.UserProfileValue));
             }
             else
             {
                 nodesToAdd.Add(new ChatNode(e.Profile[key], CssClasses.UserProfileValue));
             }
         }
         else
         {
             nodesToAdd.Add(new ChatNode(e.Profile[key], CssClasses.UserProfileValue));
         }
     }
     chat.AddChat(nodesToAdd);
 }
 void Client_UserProfileReceived(object sender, UserProfileEventArgs e)
 {
     if (__userProfileReceived != null)
         __userProfileReceived.Call(_host.ClientHost, ConvObj(e));
 }
Exemple #4
0
 public void OnUserProfileReceived(UserProfileEventArgs e)
 {
     m_host.OnUserProfileReceived(e);
 }
 public void OnUserProfileReceived(UserProfileEventArgs e)
 {
     m_host.OnUserProfileReceived(e);
 }
        private void HandleUserProfileRequest(ParseData data)
        {
            DataReader dr = new DataReader(data.Data);
            int numAccounts = dr.ReadInt32(); // should always be 1; number of accounts
            if (numAccounts != 1)
            {
                Trace.WriteLine("BN# cannot handle more than one account per user profile request; quitting.");
                BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data);
                return;
            }

            int numKeys = dr.ReadInt32();
            int requestID = dr.ReadInt32(); // request ID
            string[] keyValues = new string[numKeys];
            for (int i = 0; i < numKeys; i++)
            {
                keyValues[i] = dr.ReadCString(Encoding.UTF8);
            }

            if (m_profileRequests.ContainsKey(requestID))
            {
                UserProfileRequest req = m_profileRequests[requestID];
                int value = 0;
                foreach (UserProfileKey key in req.Keys)
                {
                    req[key] = keyValues[value++];
                }
                m_profileRequests.Remove(requestID);

                UserProfileEventArgs args = new UserProfileEventArgs(req) { EventData = data };
                OnUserProfileReceived(args);
            }
            else
            {
                Debug.WriteLine(requestID, "Unknown profile request response.");
                BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data);
                return;
            }
        }