コード例 #1
0
        /// <summary>
        /// pubilsh a car status message to the MQTT broker
        /// </summary>
        /// <param name="timestamp">message timestamp</param>
        /// <param name="index">the index for the car</param>
        /// <param name="type">the status type</param>
        /// <param name="value">the status value</param>
        private void SendCarStatus(long timestamp, int index, string type, int value)
        {
            JCarStatus status  = new JCarStatus(timestamp, index, type, value);
            string     message = JsonConvert.SerializeObject(status);

            /*
             * string message = "{ \"timestamp\": " + timestamp +
             *  ", \"carIndex\": " + index +
             *  ", \"type\": \"" + type +
             *  "\", \"value\": " + value + "}";
             */
            EnqueueMessage(CarStatusTopic, message);
        }
コード例 #2
0
        /// <summary>
        /// pubilsh a car status message to the MQTT broker
        /// </summary>
        /// <param name="timestamp">message timestamp</param>
        /// <param name="index">the index for the car</param>
        /// <param name="type">the status type</param>
        /// <param name="value">the status value</param>
        /// <returns></returns>
        private short SendCarStatus(long timestamp, int index, string type, int value)
        {
            JCarStatus status  = new JCarStatus(timestamp, index, type, value);
            string     message = JsonConvert.SerializeObject(status);

            /*
             * string message = "{ \"timestamp\": " + timestamp +
             *  ", \"carIndex\": " + index +
             *  ", \"type\": \"" + type +
             *  "\", \"value\": " + value + "}";
             */
            short msgId = PublishMessage(CarStatusTopic, message);

            return(msgId);
        }