예제 #1
0
        /// <summary>
        /// Invoked when a ping packet is received.
        /// </summary>
        /// <param name="client">The client sending the packet.</param>
        /// <param name="packet">The packet received from the client.</param>
        public static ProcessingState OnPing(IClient client, MqttPingReqPacket packet)
        {
            // Send ping response
            client.SendMqttPingResp();

            // Stop the processing
            return(ProcessingState.Stop);
        }
예제 #2
0
        private static MqttPacket Acquire(MqttPacketType type, IClient client)
        {
            switch (type)
            {
            case MqttPacketType.Connect: return(MqttConnectPacket.Acquire());

            case MqttPacketType.Subscribe: return(MqttSubscribePacket.Acquire());

            case MqttPacketType.Unsubscribe: return(MqttUnsubscribePacket.Acquire());

            case MqttPacketType.PingReq: return(MqttPingReqPacket.Acquire());

            case MqttPacketType.Disconnect: return(MqttDisconnectPacket.Acquire());

            case MqttPacketType.Publish: return(MqttPublishPacket.Acquire());

            case MqttPacketType.PubAck: return(MqttPubackPacket.Acquire());

            default:
                Service.Logger.Log("Unknown MQTT Type: " + type);
                return(null);
            }
        }