Example #1
0
        public ActionResult SendMessage(string receiver = "", int timestamp = -1, string message = "")
        {
            if (Globals.isLoggedIn() == false)
            {
                return(RedirectToAction("Index", "Authentication"));
            }

            if ("".Equals(receiver) || "".Equals(message) || timestamp == -1)
            {
                throw new System.Exception("Did not supply all required arguments.");
            }

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

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

            ChatMessage chatMessage = new ChatMessage
            {
                sender          = Globals.getUser(),
                receiver        = receiver,
                unix_timestamp  = timestamp,
                messageContents = message
            };

            SendMessageRequest request = new SendMessageRequest(chatMessage);

            connection.sendChatMessage(request);
            return(null);
        }