public GenericMqttClient(MqttConfig config, IChannel channel, IMqttDispatch dispatcher = null) { this.dispatcher = dispatcher ?? new GenericMqttDispatcher(); session = new MqttSession(config); session.OnConnect += Session_OnConnect; session.OnDisconnect += Session_OnDisconnect; session.OnRetry += Session_OnRetry; this.channel = channel; this.channel.OnReceive += Channel_OnReceive; this.channel.OnClose += Channel_OnClose; this.channel.OnError += Channel_OnError; this.channel.OnStateChange += Channel_OnStateChange; }
public GenericMqttClient(MqttConfig config, IChannel channel, IMqttDispatch dispatcher = null) { this.dispatcher = dispatcher != null ? dispatcher : new GenericMqttDispatcher(); timeoutMilliseconds = config.MaxTransmitSpan.TotalMilliseconds; session = new MqttSession(config); session.OnConnect += Session_OnConnect; session.OnDisconnect += Session_OnDisconnect; session.OnRetry += Session_OnRetry; this.channel = channel; this.channel.OnReceive += Channel_OnReceive; this.channel.OnClose += Channel_OnClose; this.channel.OnError += Channel_OnError; this.channel.OnStateChange += Channel_OnStateChange; }
public PiraeusMqttClient(MqttConfig config, IChannel channel, IMqttDispatch dispatcher = null) { this.dispatcher = dispatcher ?? new GenericMqttDispatcher(); timeoutMilliseconds = config.MaxTransmitSpan.TotalMilliseconds; session = new MqttSession(config); session.OnKeepAlive += Session_OnKeepAlive; session.OnConnect += Session_OnConnect; session.OnDisconnect += Session_OnDisconnect; session.OnRetry += Session_OnRetry; Channel = channel; Channel.OnReceive += Channel_OnReceive; Channel.OnClose += Channel_OnClose; Channel.OnError += Channel_OnError; Channel.OnStateChange += Channel_OnStateChange; queue = new Queue <byte[]>(); }
public static MqttMessageHandler Create(MqttSession session, MqttMessage message, IMqttDispatch dispatcher = null) { return(message.MessageType switch { MqttMessageType.CONNACK => new MqttConnackHandler(session, message), MqttMessageType.CONNECT => new MqttConnectHandler(session, message), MqttMessageType.DISCONNECT => new MqttDisconnectHandler(session, message), MqttMessageType.PINGREQ => new MqttPingReqHandler(session, message), MqttMessageType.PINGRESP => new MqttPingRespHandler(session, message), MqttMessageType.PUBACK => new MqttPubAckHandler(session, message), MqttMessageType.PUBCOMP => new MqttPubCompHandler(session, message), MqttMessageType.PUBLISH => new MqttPublishHandler(session, message, dispatcher), MqttMessageType.PUBREC => new MqttPubRecHandler(session, message), MqttMessageType.PUBREL => new MqttPubRelHandler(session, message, dispatcher), MqttMessageType.SUBACK => new MqttSubAckHandler(session, message), MqttMessageType.SUBSCRIBE => new MqttSubscribeHandler(session, message), MqttMessageType.UNSUBACK => new MqttUnsubAckHandler(session, message), MqttMessageType.UNSUBSCRIBE => new MqttUnsubscribeHandler(session, message), _ => throw new InvalidCastException("MqttMessageType") });
public MqttPubRelHandler(MqttSession session, MqttMessage message, IMqttDispatch dispatcher) : base(session, message, dispatcher) { }
public static MqttMessageHandler Create(MqttSession session, MqttMessage message, IMqttDispatch dispatcher = null) { switch (message.MessageType) { case MqttMessageType.CONNACK: return(new MqttConnackHandler(session, message)); case MqttMessageType.CONNECT: return(new MqttConnectHandler(session, message)); case MqttMessageType.DISCONNECT: return(new MqttDisconnectHandler(session, message)); case MqttMessageType.PINGREQ: return(new MqttPingReqHandler(session, message)); case MqttMessageType.PINGRESP: return(new MqttPingRespHandler(session, message)); case MqttMessageType.PUBACK: return(new MqttPubAckHandler(session, message)); case MqttMessageType.PUBCOMP: return(new MqttPubCompHandler(session, message)); case MqttMessageType.PUBLISH: return(new MqttPublishHandler(session, message, dispatcher)); case MqttMessageType.PUBREC: return(new MqttPubRecHandler(session, message)); case MqttMessageType.PUBREL: return(new MqttPubRelHandler(session, message, dispatcher)); case MqttMessageType.SUBACK: return(new MqttSubAckHandler(session, message)); case MqttMessageType.SUBSCRIBE: return(new MqttSubscribeHandler(session, message)); case MqttMessageType.UNSUBACK: return(new MqttUnsubAckHandler(session, message)); case MqttMessageType.UNSUBSCRIBE: return(new MqttUnsubscribeHandler(session, message)); default: throw new InvalidCastException("MqttMessageType"); } }
protected MqttMessageHandler(MqttSession session, MqttMessage message, IMqttDispatch dispatcher = null) { Session = session; Message = message; Dispatcher = dispatcher; }