コード例 #1
0
        /// <summary>
        /// Saves the reverse echo to the database
        /// </summary>
        /// <param name="echo">Information about the echo</param>
        public void saveReverseEcho(ReverseEchoRequest request)
        {
            if (openConnection() == true)
            {
                string query = @"INSERT INTO echoreverse(timestamp, username, datain)" +
                               @"VALUES('" + DateTimeOffset.Now.ToUnixTimeSeconds().ToString() +
                               @"', '" + request.username + @"', '" + request.data + @"');";

                MySqlCommand command = new MySqlCommand(query, connection);
                command.ExecuteNonQuery();

                closeConnection();
            }
            else
            {
                Debug.consoleMsg("Unable to connect to database");
            }
        }
コード例 #2
0
        /// <summary>
        /// Sends the data to the echo service, and returns the response.
        /// </summary>
        /// <param name="request">The data sent by the client</param>
        /// <returns>The response from the echo service</returns>
        private ServiceBusResponse reverseEcho(ReverseEchoRequest request)
        {
            if (authenticated == false)
            {
                return(new ServiceBusResponse(false, "Error: You must be logged in to use the echo reverse functionality."));
            }

            // This class indicates to the request function where
            SendOptions sendOptions = new SendOptions();

            sendOptions.SetDestination("Echo");

            // The Request<> funtion itself is an asynchronous operation. However, since we do not want to continue execution until the Request
            // function runs to completion, we call the ConfigureAwait, GetAwaiter, and GetResult functions to ensure that this thread
            // will wait for the completion of Request before continueing.
            return(requestingEndpoint.Request <ServiceBusResponse>(request, sendOptions).
                   ConfigureAwait(false).GetAwaiter().GetResult());
        }
コード例 #3
0
        /// <summary>
        /// This function is called by the client on the users computer when they request a reverse echo
        /// </summary>
        /// <param name="reverseText">The text to be sent to the service bus</param>
        /// <returns>An html page containing the response from the service bus</returns>
        public ActionResult ReverseEcho(string reverseText)
        {
            ReverseEchoRequest   request = new ReverseEchoRequest(reverseText, Globals.getUser());
            ServiceBusResponse   response;
            ServiceBusConnection connection = ConnectionManager.getConnectionObject(Globals.getUser());

            if (connection == null)
            {
                response = new ServiceBusResponse(false, "Error: You must be logged in to use the echo reverse functionality.");
            }
            else
            {
                response = connection.echoReverse(request);
            }

            ViewBag.ReverseResponse = response.response;

            return(View("Index"));
        }
コード例 #4
0
        /// <summary>
        /// Saves the reverse echo to the database
        /// </summary>
        /// <param name="echo">Information about the echo</param>
        public void saveReverseEcho(ReverseEchoRequest request)
        {
            if (openConnection() == true)
            {
                string query = "INSERT INTO echoreverse(timestamp, username, datain)" +
                               "VALUES(@Timestamp,@Username,@Data);";

                MySqlCommand command = new MySqlCommand(query, connection);
                command.Parameters.AddWithValue("@Timestamp", DateTimeOffset.Now.ToUnixTimeSeconds().ToString());
                command.Parameters.AddWithValue("@Username", request.username);
                command.Parameters.AddWithValue("@Data", request.data);
                command.ExecuteNonQuery();

                closeConnection();
            }
            else
            {
                Debug.consoleMsg("Unable to connect to database");
            }
        }
コード例 #5
0
 /// <summary>
 /// Sends the data to be echo'd to the service bus
 /// </summary>
 /// <param name="request">The data to be echo'd</param>
 /// <returns>The response from the servicebus</returns>
 public ServiceBusResponse echoReverse(ReverseEchoRequest request)
 {
     send(request);
     return(readUntilEOF());
 }