public Task Handle(GetChatContactsRequest message, IMessageHandlerContext context)
        {
            ChatDatabase            db       = ChatDatabase.getInstance();
            GetChatContactsResponse response = db.retrieveChatContacts(message.getCommand.usersname);

            return(context.Reply(response));
        }
Exemple #2
0
        /// <summary>
        /// Saves the echo to the database, reverses the data, and returns it back to the calling endpoint.
        /// </summary>
        /// <param name="request">Information about the echo</param>
        /// <param name="context">Used to access information regarding the endpoints used for this handle</param>
        /// <returns>The response to be sent back to the calling process</returns>
        public Task Handle(GetChatContactsRequest request, IMessageHandlerContext context)
        {
            //Save the echo to the database
            GetChatContactsResponse response = ChatServiceDatabase.getInstance().getContacts(request.getCommand.usersname);

            //The context is used to give a reply back to the endpoint that sent the request
            return(context.Reply(response));
        }
        public ActionResult Index()
        {
            if (Globals.isLoggedIn() == false)
            {
                return(RedirectToAction("Index", "Authentication"));
            }

            ServiceBusConnection connection = ConnectionManager.getConnectionObject(Globals.getUser());

            if (connection == null)
            {
                return(RedirectToAction("Index", "Authentication"));
            }

            GetChatContacts getContactsCommand = new GetChatContacts
            {
                usersname    = Globals.getUser(),
                contactNames = null
            };

            GetChatContactsRequest  contactsRequest  = new GetChatContactsRequest(getContactsCommand);
            GetChatContactsResponse contactsResponse = connection.getAllChatContacts(contactsRequest);

            ChatHistory firstDisplayedChatHistory = null;

            if (contactsResponse.responseData.contactNames.Count != 0)
            {
                GetChatHistory getHistoryCommand = new GetChatHistory()
                {
                    history = new ChatHistory
                    {
                        user1 = Globals.getUser(),
                        user2 = contactsResponse.responseData.contactNames[0]
                    }
                };

                GetChatHistoryRequest historyRequest = new GetChatHistoryRequest(getHistoryCommand);
                firstDisplayedChatHistory = connection.getChatHistory(historyRequest).responseData.history;
            }
            else
            {
                firstDisplayedChatHistory = new ChatHistory();
            }

            ViewBag.ChatInstances        = contactsResponse.responseData.contactNames;
            ViewBag.DisplayedChatHistory = firstDisplayedChatHistory;

            return(View());
        }
Exemple #4
0
        /// <summary>
        /// Searches for company information
        /// </summary>
        /// <param name="message">Information about the company</param>
        /// <param name="context">Used to access information regarding the endpoints used for this handle</param>
        /// <returns>The response to be sent back to the calling process</returns>
        public Task Handle(GetChatContactsRequest message, IMessageHandlerContext context)
        {
            GetChatContactsResponse response;
            // TODO: May need to fix. Currently hardcoded to always retrieve client contacts.
            GetChatContacts conts = new GetChatContacts(message.getCommand.usersname, ChatDatabase.getInstance().getContacts(message.getCommand.usersname));

            if (conts.contactNames.Count == 0)
            {
                response = new GetChatContactsResponse(false, "Could not find any contacts.", conts);
            }
            else
            {
                response = new GetChatContactsResponse(true, "Successfully retrieved contacts.", conts);
            }

            return(context.Reply(response));
        }
Exemple #5
0
        /// <summary>
        /// Searches the chat database for the names of all other users the given user has made chat contact with
        /// </summary>
        /// <param name="message">The command object that was sent</param>
        /// <param name="context">Contains information relevent to the current command being handled.</param>
        /// <returns>The command object with the contactnames property filled</returns>
        public Task Handle(GetChatContactsRequest message, IMessageHandlerContext context)
        {
            GetChatContactsResponse dbResponse = ChatServiceDatabase.getInstance().getAllChatContactsForUser(message);

            return(context.Reply(dbResponse));
        }