Exemplo n.º 1
0
 public ChatResult AddFriendRequest(string friendId)
 {
     ChatResult result = Manager.Instance.AddFriendRequest(Context.ConnectionId, friendId);
     if (result.Success)
     {
         CustomerInfo customer = Manager.Instance.GetCustomerByConnectionId(Context.ConnectionId);
         CustomerInfo returnCustomer = new CustomerInfo(customer.CustomerId, customer.CustomerName, customer.Status);
         List<string> friendConnectionIds = Manager.Instance.GetCustomerByCustomerId(friendId).ConnectionList;
         Clients.Clients(friendConnectionIds).OnAddFriendRequest(returnCustomer);
     }
     return result;
 }
Exemplo n.º 2
0
        public ChatResult AddFriendRespond(string friendId, bool agree)
        {
            ChatResult result = Manager.Instance.AddFriendRespond(Context.ConnectionId, friendId, agree);
            if (result.Success)
            {
                CustomerInfo myCustomer = Manager.Instance.GetCustomerByConnectionId(Context.ConnectionId);
                CustomerInfo friendCustomer = Manager.Instance.GetCustomerByCustomerId(friendId);

                CustomerInfo returnMyCustomer = new CustomerInfo(myCustomer.CustomerId, myCustomer.CustomerName, myCustomer.Status);
                CustomerInfo returnFriendCustomer = new CustomerInfo(friendCustomer.CustomerId, friendCustomer.CustomerName, friendCustomer.Status);
                //send to request customer
                //gửi về 2 thông tin: bool agree, Customer
                Clients.Clients(friendCustomer.ConnectionList).OnAddFriendRespond(agree, returnMyCustomer);

                //send to respond customer
                //gửi về 2 thông tin nếu bool agree = true : customerid, string name
                if (agree == true)
                    Clients.Clients(myCustomer.ConnectionList).OnAddFriendRespond(agree, returnFriendCustomer);
            }
            return result;
        }
Exemplo n.º 3
0
 public List<CustomerInfo> SearchCustomerByCustomerName(string connectionId, string customerId)
 {
     if (m_mapConnectionIdCustomer.ContainsKey(connectionId))
     {
         List<CustomerInfo> cusList = m_customerInfoDict.Values.Where(t => t.CustomerId.Contains(customerId)).ToList();
         List<CustomerInfo> sendCustomerList = new List<CustomerInfo>();
         foreach (CustomerInfo cus in cusList)
         {
             CustomerInfo newCus = new CustomerInfo(cus.CustomerId, cus.CustomerName, cus.Status);
             sendCustomerList.Add(newCus);
         }
         return sendCustomerList;
     }
     return null;
 }
Exemplo n.º 4
0
 /// <summary>
 /// trong trường hợp GetFriendRequest thì key sẽ là ID của friend, value là friend mà request đến mình
 /// </summary>
 /// <param name="connectionId"></param>
 /// <returns></returns>
 public List<CustomerInfo> GetFriendRequest(string connectionId)
 {
     if (m_mapConnectionIdCustomer.ContainsKey(connectionId))
     {
         string myCustomerId = m_mapConnectionIdCustomer[connectionId];
         List<CustomerInfo> requestList = new List<CustomerInfo>();
         if (m_requestAddFriendDict.ContainsKey(myCustomerId))
         {
             foreach (string friendId in m_requestAddFriendDict[myCustomerId])
             {
                 CustomerInfo cus = m_customerInfoDict[friendId];
                 CustomerInfo friendCus = new CustomerInfo(cus.CustomerId, cus.CustomerName, cus.Status);
                 requestList.Add(friendCus);
             }
         }
         return requestList;
     }
     return null;
 }
Exemplo n.º 5
0
 public List<CustomerInfo> GetFriendListByCustomerId(string connectionId)
 {
     if (m_mapConnectionIdCustomer.ContainsKey(connectionId))
     {
         string myCustomerId = m_mapConnectionIdCustomer[connectionId];
         List<CustomerInfo> customerList = new List<CustomerInfo>();
         List<string> friendIdList = m_customerInfoDict[myCustomerId].FriendList;
         foreach (string friendId in friendIdList)
         {
             CustomerInfo cus = m_customerInfoDict[friendId];
             CustomerInfo newCus = new CustomerInfo(cus.CustomerId, cus.CustomerName, cus.Status);
             customerList.Add(newCus);
         }
         return customerList;
     }
     return null;
 }