示例#1
0
        /// <summary>
        /// Publishes an EchoEvent.
        /// </summary>
        /// <param name="request">The data to be echo'd back to the client</param>
        /// <returns>The data sent by the client</returns>
        private ServiceBusResponse asIsEcho(AsIsEchoRequest request)
        {
            AsIsEchoEvent echoEvent = new AsIsEchoEvent
            {
                data     = request.data,
                username = username
            };

            //This function publishes the EchoEvent class. All endpoint instances that subscribed to these events prior
            //to the event being published will have their respictive handler functions called with the EchoEvent object
            //as one of the parameters
            eventPublishingEndpoint.Publish(echoEvent);
            return(new ServiceBusResponse(true, request.data));
        }
示例#2
0
        /// <summary>
        /// Saves the foreward echo to the database
        /// </summary>
        /// <param name="echo">Information about the echo</param>
        public void saveAsIsEcho(AsIsEchoEvent echo)
        {
            if (openConnection() == true)
            {
                string query = @"INSERT INTO echoforward(timestamp, username, datain)" +
                               @"VALUES('" + DateTimeOffset.Now.ToUnixTimeSeconds().ToString() +
                               @"', '" + echo.username + @"', '" + echo.data + @"');";

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

                closeConnection();
            }
            else
            {
                Debug.consoleMsg("Unable to connect to database");
            }
        }
        /// <summary>
        /// Saves the foreward echo to the database
        /// </summary>
        /// <param name="echo">Information about the echo</param>
        public void saveAsIsEcho(AsIsEchoEvent echo)
        {
            if (openConnection() == true)
            {
                string query = "INSERT INTO echoforward(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", echo.username);
                command.Parameters.AddWithValue("@Data", echo.data);
                command.ExecuteNonQuery();

                closeConnection();
            }
            else
            {
                Debug.consoleMsg("Unable to connect to database");
            }
        }