Beispiel #1
0
        /// <summary>
        /// Invoked when a disconnect 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 OnDisconnect(IClient client, MqttDisconnectPacket packet)
        {
            // Close the connection
            client.Dispose();

            // Stop the processing
            return(ProcessingState.Stop);
        }
Beispiel #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);
            }
        }