├── .editorconfig ├── .gitattributes ├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ ├── feature_request.md │ └── question.md ├── PULL_REQUEST_TEMPLATE.md ├── SECURITY.md ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── build.yml │ ├── codeql-analysis.yml │ ├── dependabot-auto-merge.yml │ ├── greetings.yml │ └── release-drafter.yml ├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── Benchmarks └── ClientBenchmarkApp │ ├── ClientBenchmark.cs │ ├── ClientBenchmarkApp.csproj │ ├── Program.cs │ └── README.md ├── Directory.Build.props ├── Directory.Build.targets ├── Documentation ├── .gitignore ├── README.md ├── babel.config.js ├── docfx.json ├── docs │ ├── benchmarks.md │ ├── connecting.md │ ├── events │ │ ├── Events.md │ │ ├── Examples.md │ │ ├── Reference.md │ │ └── _category_.json │ ├── help.md │ ├── how-to │ │ ├── _category_.json │ │ ├── allow-invalid-certs.md │ │ ├── client-certificates.md │ │ ├── configure-logging.md │ │ ├── connect-with-auth.md │ │ ├── debug.md │ │ ├── set-lwt.md │ │ └── wait-on-event.md │ ├── intro.md │ ├── namespaces.md │ ├── publishing.md │ ├── quickstart.md │ ├── reference │ │ ├── _category_.json │ │ ├── automatic_reconnect.md │ │ ├── client_options.md │ │ ├── client_options_builder.md │ │ ├── connect_options.md │ │ ├── connect_options_builder.md │ │ ├── disconnect_options.md │ │ ├── disconnect_options_builder.md │ │ ├── last_will_and_testament.md │ │ ├── last_will_and_testament_builder.md │ │ ├── publish_message.md │ │ ├── publish_message_builder.md │ │ ├── subscribe_options.md │ │ ├── subscribe_options_builder.md │ │ ├── unsubscribe_options.md │ │ └── unsubscribe_options_builder.md │ └── subscribing.md ├── docusaurus.config.js ├── package-lock.json ├── package.json ├── sidebars.js ├── src │ ├── components │ │ ├── HomepageFeatures │ │ │ ├── index.js │ │ │ └── styles.module.css │ │ └── HomepageIntro │ │ │ ├── index.js │ │ │ └── styles.module.css │ ├── css │ │ └── custom.css │ └── pages │ │ ├── index.js │ │ ├── index.module.css │ │ └── markdown-page.md ├── static │ ├── .nojekyll │ ├── img │ │ ├── client-logo-two.png │ │ ├── client-logo.png │ │ ├── csharp-logo.png │ │ ├── dotnet-bot_iot.png │ │ ├── dotnet-logo.png │ │ ├── easy-to-use.jpg │ │ ├── favicon.ico │ │ ├── high-quality.jpg │ │ ├── logo.png │ │ └── reliable.jpg │ └── public │ │ ├── bootstrap-icons-BNVXHMH5.woff │ │ ├── bootstrap-icons-UDRIHJCM.woff2 │ │ ├── c4Diagram-817c8e44-SGFOBFRD.min.js │ │ ├── c4Diagram-817c8e44-SGFOBFRD.min.js.map │ │ ├── chunk-334IV3XH.min.js │ │ ├── chunk-334IV3XH.min.js.map │ │ ├── chunk-3RELVOUY.min.js │ │ ├── chunk-3RELVOUY.min.js.map │ │ ├── chunk-CK25GZVZ.min.js │ │ ├── chunk-CK25GZVZ.min.js.map │ │ ├── chunk-CXT7N4L6.min.js │ │ ├── chunk-CXT7N4L6.min.js.map │ │ ├── chunk-DALFUHAB.min.js │ │ ├── chunk-DALFUHAB.min.js.map │ │ ├── chunk-EKFGDCJ4.min.js │ │ ├── chunk-EKFGDCJ4.min.js.map │ │ ├── chunk-F7JJDB3C.min.js │ │ ├── chunk-F7JJDB3C.min.js.map │ │ ├── chunk-I64Z623A.min.js │ │ ├── chunk-I64Z623A.min.js.map │ │ ├── chunk-P42HNYSU.min.js │ │ ├── chunk-P42HNYSU.min.js.map │ │ ├── chunk-U66T5BMR.min.js │ │ ├── chunk-U66T5BMR.min.js.map │ │ ├── chunk-YAMJ4ASO.min.js │ │ ├── chunk-YAMJ4ASO.min.js.map │ │ ├── chunk-YICCS3KT.min.js │ │ ├── chunk-YICCS3KT.min.js.map │ │ ├── classDiagram-48ab76fb-2NS2GWUH.min.js │ │ ├── classDiagram-48ab76fb-2NS2GWUH.min.js.map │ │ ├── classDiagram-v2-8ecb0bfc-NYCPINMQ.min.js │ │ ├── classDiagram-v2-8ecb0bfc-NYCPINMQ.min.js.map │ │ ├── docfx.min.css │ │ ├── docfx.min.css.map │ │ ├── docfx.min.js │ │ ├── docfx.min.js.map │ │ ├── erDiagram-9cfc3649-NX6WFSGQ.min.js │ │ ├── erDiagram-9cfc3649-NX6WFSGQ.min.js.map │ │ ├── es-BVOT75G5.min.js │ │ ├── es-BVOT75G5.min.js.map │ │ ├── flowDiagram-61eb444c-W2MZ7QST.min.js │ │ ├── flowDiagram-61eb444c-W2MZ7QST.min.js.map │ │ ├── flowDiagram-v2-2f8f667a-WVVXSXHH.min.js │ │ ├── flowDiagram-v2-2f8f667a-WVVXSXHH.min.js.map │ │ ├── flowchart-elk-definition-e097735e-EIOOWBCS.min.js │ │ ├── flowchart-elk-definition-e097735e-EIOOWBCS.min.js.map │ │ ├── ganttDiagram-db6931fb-KM4XNDUI.min.js │ │ ├── ganttDiagram-db6931fb-KM4XNDUI.min.js.map │ │ ├── gitGraphDiagram-6b463803-XW36YSNI.min.js │ │ ├── gitGraphDiagram-6b463803-XW36YSNI.min.js.map │ │ ├── infoDiagram-a336098b-M3EGNS5K.min.js │ │ ├── infoDiagram-a336098b-M3EGNS5K.min.js.map │ │ ├── journeyDiagram-deae3313-2YUPEA7J.min.js │ │ ├── journeyDiagram-deae3313-2YUPEA7J.min.js.map │ │ ├── lunr.ar-E7GAKDHK.min.js │ │ ├── lunr.ar-E7GAKDHK.min.js.map │ │ ├── lunr.da-WZCDGCDT.min.js │ │ ├── lunr.da-WZCDGCDT.min.js.map │ │ ├── lunr.de-7XZMXZII.min.js │ │ ├── lunr.de-7XZMXZII.min.js.map │ │ ├── lunr.du-QL47PPFK.min.js │ │ ├── lunr.du-QL47PPFK.min.js.map │ │ ├── lunr.el-6EBCVLMJ.min.js │ │ ├── lunr.el-6EBCVLMJ.min.js.map │ │ ├── lunr.es-4YT3M4ID.min.js │ │ ├── lunr.es-4YT3M4ID.min.js.map │ │ ├── lunr.fi-TLAOR23U.min.js │ │ ├── lunr.fi-TLAOR23U.min.js.map │ │ ├── lunr.fr-G4S422VA.min.js │ │ ├── lunr.fr-G4S422VA.min.js.map │ │ ├── lunr.he-J62KVQ3T.min.js │ │ ├── lunr.he-J62KVQ3T.min.js.map │ │ ├── lunr.hi-VEBDFZQ2.min.js │ │ ├── lunr.hi-VEBDFZQ2.min.js.map │ │ ├── lunr.hu-ZCNH23T6.min.js │ │ ├── lunr.hu-ZCNH23T6.min.js.map │ │ ├── lunr.hy-XFQCAWFO.min.js │ │ ├── lunr.hy-XFQCAWFO.min.js.map │ │ ├── lunr.it-43SEBRLN.min.js │ │ ├── lunr.it-43SEBRLN.min.js.map │ │ ├── lunr.ja-6645DQV5.min.js │ │ ├── lunr.ja-6645DQV5.min.js.map │ │ ├── lunr.jp-2KRE2L63.min.js │ │ ├── lunr.jp-2KRE2L63.min.js.map │ │ ├── lunr.kn-EGFANKI2.min.js │ │ ├── lunr.kn-EGFANKI2.min.js.map │ │ ├── lunr.ko-64QAI4XT.min.js │ │ ├── lunr.ko-64QAI4XT.min.js.map │ │ ├── lunr.nl-JVT7LKKG.min.js │ │ ├── lunr.nl-JVT7LKKG.min.js.map │ │ ├── lunr.no-SUO4TTOY.min.js │ │ ├── lunr.no-SUO4TTOY.min.js.map │ │ ├── lunr.pt-EAA2HV6I.min.js │ │ ├── lunr.pt-EAA2HV6I.min.js.map │ │ ├── lunr.ro-U2ICUNNF.min.js │ │ ├── lunr.ro-U2ICUNNF.min.js.map │ │ ├── lunr.ru-5AQBX5R2.min.js │ │ ├── lunr.ru-5AQBX5R2.min.js.map │ │ ├── lunr.sa-M7TYHLRJ.min.js │ │ ├── lunr.sa-M7TYHLRJ.min.js.map │ │ ├── lunr.sv-K3GSGWC2.min.js │ │ ├── lunr.sv-K3GSGWC2.min.js.map │ │ ├── lunr.ta-AKIPBQLC.min.js │ │ ├── lunr.ta-AKIPBQLC.min.js.map │ │ ├── lunr.te-OBAK5FVS.min.js │ │ ├── lunr.te-OBAK5FVS.min.js.map │ │ ├── lunr.th-LSQ6T65I.min.js │ │ ├── lunr.th-LSQ6T65I.min.js.map │ │ ├── lunr.tr-T3KKXR52.min.js │ │ ├── lunr.tr-T3KKXR52.min.js.map │ │ ├── lunr.vi-S3VOAA5A.min.js │ │ ├── lunr.vi-S3VOAA5A.min.js.map │ │ ├── main.css │ │ ├── main.js │ │ ├── mermaid.core-TOXYJXQE.min.js │ │ ├── mermaid.core-TOXYJXQE.min.js.map │ │ ├── mindmap-definition-617cf8dd-4PM2AKSZ.min.js │ │ ├── mindmap-definition-617cf8dd-4PM2AKSZ.min.js.map │ │ ├── pieDiagram-a5166659-EQCDURPM.min.js │ │ ├── pieDiagram-a5166659-EQCDURPM.min.js.map │ │ ├── quadrantDiagram-6c355bbc-H5XRRV3H.min.js │ │ ├── quadrantDiagram-6c355bbc-H5XRRV3H.min.js.map │ │ ├── requirementDiagram-4038b16c-35KSP34O.min.js │ │ ├── requirementDiagram-4038b16c-35KSP34O.min.js.map │ │ ├── sankeyDiagram-6db3d513-UAUVVQE6.min.js │ │ ├── sankeyDiagram-6db3d513-UAUVVQE6.min.js.map │ │ ├── search-worker.min.js │ │ ├── search-worker.min.js.map │ │ ├── sequenceDiagram-465a088a-72KISVBJ.min.js │ │ ├── sequenceDiagram-465a088a-72KISVBJ.min.js.map │ │ ├── stateDiagram-b620d43f-6XMSQQAT.min.js │ │ ├── stateDiagram-b620d43f-6XMSQQAT.min.js.map │ │ ├── stateDiagram-v2-2671c3d1-GBFY3N5Z.min.js │ │ ├── stateDiagram-v2-2671c3d1-GBFY3N5Z.min.js.map │ │ ├── tex-svg-full-3JRN7JHV.min.js │ │ ├── tex-svg-full-3JRN7JHV.min.js.map │ │ ├── timeline-definition-732a2638-NYHTUS3Z.min.js │ │ ├── timeline-definition-732a2638-NYHTUS3Z.min.js.map │ │ ├── xychartDiagram-f746c04c-RVX2Y5TN.min.js │ │ └── xychartDiagram-f746c04c-RVX2Y5TN.min.js.map └── yarn.lock ├── Examples ├── ConnectReceiveAndPublish │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ ├── ConnectReceiveAndPublish.csproj │ ├── Program.cs │ └── README.md ├── HiveMQtt-CLI │ ├── HiveMQtt-CLI.sln │ ├── HiveMQtt-CLI │ │ ├── HiveMQtt-CLI.csproj │ │ └── Program.cs │ └── README.md ├── Logging │ ├── NLog.config │ └── README.md ├── SendMessageOnLoop │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ ├── Program.cs │ ├── README.md │ └── SendMessageOnLoop.csproj └── SubscriberWithEvents │ ├── Program.cs │ ├── README.md │ └── SubscriberWithEvents.csproj ├── HEADER ├── HiveMQtt.sln ├── Images ├── Banner.png ├── Hero.png ├── Icon.png ├── csharp-logo.png └── hivemq-mqtt-client.png ├── LICENSE ├── README.md ├── Source ├── Directory.Build.props └── HiveMQtt │ ├── Client │ ├── ConnectOptionsbuilder.cs │ ├── Connection │ │ ├── ConnectionManager.cs │ │ ├── ConnectionManagerHandlers.cs │ │ └── ConnectionManagerTasks.cs │ ├── DisconnectOptionsBuilder.cs │ ├── Events │ │ ├── AfterConnectEventArgs.cs │ │ ├── AfterDisconnectEventArgs.cs │ │ ├── AfterSubscribeEventArgs.cs │ │ ├── AfterUnsubscribeEventArgs.cs │ │ ├── BeforeConnectEventArgs.cs │ │ ├── BeforeDisconnectEventArgs.cs │ │ ├── BeforeSubscribeEventArgs.cs │ │ ├── BeforeUnsubscribeEventArgs.cs │ │ ├── OnConnAckReceivedEventArgs.cs │ │ ├── OnConnectSentEventArgs.cs │ │ ├── OnDisconnectReceivedEventArgs.cs │ │ ├── OnDisconnectSentEventArgs.cs │ │ ├── OnMessageReceivedEventArgs.cs │ │ ├── OnPingReqSentEventArgs.cs │ │ ├── OnPingRespReceivedEventArgs.cs │ │ ├── OnPubAckReceivedEventArgs.cs │ │ ├── OnPubAckSentEventArgs.cs │ │ ├── OnPubCompReceivedEventArgs.cs │ │ ├── OnPubCompSentEventArgs.cs │ │ ├── OnPubRecReceivedEventArgs.cs │ │ ├── OnPubRecSentEventArgs.cs │ │ ├── OnPubRelReceivedEventArgs.cs │ │ ├── OnPubRelSentEventArgs.cs │ │ ├── OnPublishQoS1CompleteEventArgs.cs │ │ ├── OnPublishQoS2CompleteEventArgs.cs │ │ ├── OnPublishReceivedEventArgs.cs │ │ ├── OnPublishSentEventArgs.cs │ │ ├── OnSubAckReceivedEventArgs.cs │ │ ├── OnSubscribeSentEventArgs.cs │ │ ├── OnUnsubAckReceivedEventArgs.cs │ │ └── OnUnsubscribeSentEventArgs.cs │ ├── Exceptions │ │ └── HiveMQttClientException.cs │ ├── HiveMQClient.cs │ ├── HiveMQClientConnection.cs │ ├── HiveMQClientEvents.cs │ ├── HiveMQClientOptionsBuilder.cs │ ├── HiveMQClientUtil.cs │ ├── IHiveMQClient.cs │ ├── LastWillAndTestament.cs │ ├── LastWillAndTestamentBuilder.cs │ ├── Options │ │ ├── ConnectOptions.cs │ │ ├── DisconnectOptions.cs │ │ ├── HiveMQClientOptions.cs │ │ ├── SubscribeOptions.cs │ │ └── UnsubscribeOptions.cs │ ├── PublishMessageBuilder.cs │ ├── ReasonCodes │ │ ├── QoS1ReasonCode.cs │ │ └── QoS2ReasonCode.cs │ ├── Results │ │ ├── ConnectResult.cs │ │ ├── PublishResult.cs │ │ ├── SubscribeResult.cs │ │ └── UnsubscribeResult.cs │ ├── SubscribeOptionsBuilder.cs │ ├── Transport │ │ ├── BaseTransport.cs │ │ ├── TCPTransport.cs │ │ ├── TransportReadResult.cs │ │ └── WebSocketTransport.cs │ ├── UnsubscribeOptionsBuilder.cs │ └── internal │ │ ├── AwaitableQueueX.cs │ │ ├── BoundedDictionaryX.cs │ │ ├── ConnectState.cs │ │ ├── PacketIDManager.cs │ │ └── Validator.cs │ ├── GlobalSuppressions.cs │ ├── HiveMQtt.csproj │ ├── HiveMQtt.sln │ ├── MQTT5 │ ├── ControlPacket.cs │ ├── Exceptions │ │ ├── MQTTProtocolException.cs │ │ └── MalformedVBIException.cs │ ├── MalformedPacket.cs │ ├── PacketDecoder.cs │ ├── Packets │ │ ├── AuthPacket.cs │ │ ├── ConnAckPacket.cs │ │ ├── ConnectPacket.cs │ │ ├── DisconnectPacket.cs │ │ ├── PartialPacket.cs │ │ ├── PingReqPacket.cs │ │ ├── PingRespPacket.cs │ │ ├── PubAckPacket.cs │ │ ├── PubCompPacket.cs │ │ ├── PubRecPacket.cs │ │ ├── PubRelPacket.cs │ │ ├── PublishPacket.cs │ │ ├── SubAckPacket.cs │ │ ├── SubscribePacket.cs │ │ ├── UnsubAckPacket.cs │ │ └── UnsubscribePacket.cs │ ├── ReasonCodes │ │ ├── AuthReasonCode.cs │ │ ├── ConnAckReasonCode.cs │ │ ├── DisconnectReasonCode.cs │ │ ├── PubAckReasonCode.cs │ │ ├── PubCompReasonCode.cs │ │ ├── PubRecReasonCode.cs │ │ ├── PubRelReasonCode.cs │ │ ├── SubAckReasonCode.cs │ │ └── UnsubAckReasonCode.cs │ └── Types │ │ ├── ControlPacketType.cs │ │ ├── MQTT5DataType.cs │ │ ├── MQTT5LastWillProperties.cs │ │ ├── MQTT5PayloadFormatIndicator.cs │ │ ├── MQTT5Properties.cs │ │ ├── MQTT5Property.cs │ │ ├── MQTT5PropertyType.cs │ │ ├── MQTT5PublishMessage.cs │ │ ├── QualityOfService.cs │ │ ├── RetainHandling.cs │ │ ├── Subscription.cs │ │ ├── TopicFilter.cs │ │ └── VariableByteInteger.cs │ ├── NLog.config │ └── Properties │ └── AssemblyInfo.cs ├── StyleCop.Analyzers.ruleset ├── Tests ├── .editorconfig ├── Directory.Build.props └── HiveMQtt.Test │ ├── HiveMQClient │ ├── ClientOptionsBuilderTest.cs │ ├── ClientOptionsTest.cs │ ├── ClientTest.cs │ ├── ConnectOptions.cs │ ├── ConnectTest.cs │ ├── EventExceptionHandlingTest.cs │ ├── LWTTest.cs │ ├── LastWillAndTestamentBuilderTest.cs │ ├── Operational │ │ └── QueuedPublishesTest.cs │ ├── OptionsTest.cs │ ├── Plan │ │ ├── BrokerEnforcementTest.cs │ │ ├── KeepAliveTest.cs │ │ ├── PacketIDManagerTest.cs │ │ ├── PacketRestrictionsTest.cs │ │ ├── SessionExpiryTest.cs │ │ └── Utf8LimitTest.cs │ ├── PubSubTest.cs │ ├── PublishBuilderTest.cs │ ├── PublishTest.cs │ ├── SubscribeBuilderTest.cs │ ├── SubscribeTest.cs │ ├── TLSTest.cs │ ├── TestFiles │ │ └── hivemq-server-cert.pem │ ├── UnsubscribeBuilderTest.cs │ ├── UnsubscribeTest.cs │ ├── UtilTest.cs │ └── WebSocket │ │ ├── ConnectTest.cs │ │ ├── PubSubTest.cs │ │ ├── PublishTest.cs │ │ ├── SubscribeTest.cs │ │ └── UnsubscribeTest.cs │ ├── HiveMQtt.Test.csproj │ ├── Packets │ ├── ConnectPacketTest.cs │ └── ControlPacketTest.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Queues │ ├── AwaitableQueueXTest.cs │ └── BoundedDictionaryXTest.cs │ └── xunit.runner.json ├── build.cake ├── dotnet-tools.json └── stylecop.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################### 2 | # Git Line Endings # 3 | ############################### 4 | 5 | # Set default behavior to automatically normalize line endings. 6 | * text=auto 7 | 8 | # Force batch scripts to always use CRLF line endings so that if a repo is accessed 9 | # in Windows via a file share from Linux, the scripts will work. 10 | *.{cmd,[cC][mM][dD]} text eol=crlf 11 | *.{bat,[bB][aA][tT]} text eol=crlf 12 | 13 | # Force bash scripts to always use LF line endings so that if a repo is accessed 14 | # in Unix via a file share from Windows, the scripts will work. 15 | *.sh text eol=lf 16 | 17 | ############################### 18 | # Git Large File System (LFS) # 19 | ############################### 20 | 21 | # Archives 22 | *.7z filter=lfs diff=lfs merge=lfs -text 23 | *.br filter=lfs diff=lfs merge=lfs -text 24 | *.gz filter=lfs diff=lfs merge=lfs -text 25 | *.tar filter=lfs diff=lfs merge=lfs -text 26 | *.zip filter=lfs diff=lfs merge=lfs -text 27 | 28 | # Documents 29 | *.pdf filter=lfs diff=lfs merge=lfs -text 30 | 31 | # Images 32 | *.gif filter=lfs diff=lfs merge=lfs -text 33 | *.ico filter=lfs diff=lfs merge=lfs -text 34 | *.jpg filter=lfs diff=lfs merge=lfs -text 35 | *.png filter=lfs diff=lfs merge=lfs -text 36 | *.psd filter=lfs diff=lfs merge=lfs -text 37 | *.webp filter=lfs diff=lfs merge=lfs -text 38 | 39 | # Fonts 40 | *.woff2 filter=lfs diff=lfs merge=lfs -text 41 | 42 | # Other 43 | *.exe filter=lfs diff=lfs merge=lfs -text 44 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # HiveMQ Code of Conduct 2 | 3 | Please refer to our [HiveMQ Code of Conduct](https://github.com/hivemq/hivemq-community/blob/master/code-of-conduct.md). 4 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # All contributions, however small are valued! 2 | 3 | # Steps to contribute 4 | 5 | If you want to make a small change, go ahead and raise a pull request, otherwise follow these steps: 6 | 7 | 1. View the [Issues](https://github.com/Username/Project/issues) page to see a To-Do list of things to be implemented. 8 | 2. Raise an issue or comment on an existing issue with what you want to contribute if one does not already exist. 9 | 3. When you get the go ahead, follow the coding guidelines and raise a pull request. 10 | 4. Include a link to the issue in your pull request. 11 | 12 | # Coding Guidelines 13 | 14 | - Projects use StyleCop and .editorconfig to produce style warnings. Please fix all warnings in any code you submit. 15 | - Write unit tests for any code written. 16 | 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug report 3 | about: If something isn't working 🔧 4 | title: '' 5 | labels: bug 6 | assignees: 7 | --- 8 | 9 | ## 🐛 Bug Report 10 | 11 | 12 | 13 | 14 | 15 | ## 🔬 How To Reproduce 16 | 17 | Steps to reproduce the behavior: 18 | 19 | 1. ... 20 | 21 | ### Code sample 22 | 23 | 24 | 25 | ### Environment 26 | 27 | Where are you running/using this client? 28 | 29 | What version of this client are you using? 30 | 31 | Operating System? 32 | 33 | Hardware or Device? 34 | 35 | ### Screenshots 36 | 37 | 38 | 39 | ## 📈 Expected behavior 40 | 41 | 42 | 43 | ## 📎 Additional context 44 | 45 | 46 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # Configuration: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository 2 | 3 | blank_issues_enabled: false 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🚀 Feature request 3 | about: Suggest an idea for this project 🏖 4 | title: '' 5 | labels: enhancement 6 | assignees: 7 | --- 8 | 9 | ## 🚀 Feature Request 10 | 11 | 12 | 13 | ## 🔈 Motivation 14 | 15 | 16 | 17 | ## 🛰 Alternatives 18 | 19 | 20 | 21 | ## 📎 Additional context 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ❓ Question 3 | about: Ask a question about this project 🎓 4 | title: '' 5 | labels: question 6 | assignees: 7 | --- 8 | 9 | ## Checklist 10 | 11 | 12 | 13 | 14 | 15 | - [ ] I've searched the project's [`issues`](https://github.com/hivemq/hivemq-mqtt-client-dotnet/issues?q=is%3Aissue). 16 | - [ ] I've searched the project's [`discussions`](https://github.com/hivemq/hivemq-mqtt-client-dotnet/discussions). 17 | 18 | ## ❓ Question 19 | 20 | 21 | 22 | How can I [...]? 23 | 24 | Is it possible to [...]? 25 | 26 | ## 📎 Additional context 27 | 28 | 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | 4 | 5 | ## Related Issue 6 | 7 | 8 | 9 | ## Type of Change 10 | 11 | 12 | 13 | - [ ] 📚 Examples / docs / tutorials / dependencies update 14 | - [ ] 🔧 Bug fix (non-breaking change which fixes an issue) 15 | - [ ] 🥂 Improvement (non-breaking change which improves an existing feature) 16 | - [ ] 🚀 New feature (non-breaking change which adds functionality) 17 | - [ ] 💥 Breaking change (fix or feature that would cause existing functionality to change) 18 | - [ ] 🔐 Security fix 19 | 20 | ## Checklist 21 | 22 | 23 | 24 | - [ ] I've written tests (if applicable) for all new methods and classes that I created. (`rake test`) 25 | - [ ] I've added documentation as necessary so users can easily use and understand this feature/fix. 26 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | This project supports only the latest version with security updates. However, we'll do our best to help and answer questions about older versions. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | Contact the HiveMQ [Support Team](mailto:support@hivemq.com) to report a security vulnerability. Reports will be greatly appreciated! 10 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Configuration: https://dependabot.com/docs/config-file/ 2 | # Docs: https://docs.github.com/en/github/administering-a-repository/keeping-your-dependencies-updated-automatically 3 | 4 | version: 2 5 | 6 | updates: 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "daily" 11 | allow: 12 | - dependency-type: "all" 13 | commit-message: 14 | prefix: ":arrow_up:" 15 | open-pull-requests-limit: 50 16 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | # Release drafter configuration https://github.com/release-drafter/release-drafter#configuration 2 | # Emojis were chosen to match the https://gitmoji.carloscuesta.me/ 3 | 4 | name-template: "v$NEXT_PATCH_VERSION" 5 | tag-template: "v$NEXT_PATCH_VERSION" 6 | 7 | categories: 8 | - title: ":rocket: Features" 9 | labels: [enhancement, feature] 10 | - title: ":wrench: Fixes & Refactoring" 11 | labels: [bug, refactoring, bugfix, fix] 12 | - title: ":package: Build System & CI/CD" 13 | labels: [build, ci, testing] 14 | - title: ":boom: Breaking Changes" 15 | labels: [breaking] 16 | - title: ":pencil: Documentation" 17 | labels: [documentation] 18 | - title: ":arrow_up: Dependencies updates" 19 | labels: [dependencies] 20 | 21 | template: | 22 | ## What’s Changed 23 | 24 | $CHANGES 25 | 26 | ## :busts_in_silhouette: List of contributors 27 | 28 | $CONTRIBUTORS 29 | 30 | ## NuGet Package 31 | 32 | v$NEXT_PATCH_VERSION is available on NuGet: 33 | https://www.nuget.org/packages/HiveMQtt/$NEXT_PATCH_VERSION 34 | -------------------------------------------------------------------------------- /.github/workflows/dependabot-auto-merge.yml: -------------------------------------------------------------------------------- 1 | name: Dependabot Automerge 2 | 3 | on: 4 | pull_request: 5 | branches: [ main ] 6 | 7 | jobs: 8 | auto-merge: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4.2.2 12 | - uses: ahmadnassri/action-dependabot-auto-merge@v2 13 | with: 14 | target: minor 15 | github-token: ${{ secrets.AUTOMERGE_TOKEN }} 16 | -------------------------------------------------------------------------------- /.github/workflows/greetings.yml: -------------------------------------------------------------------------------- 1 | name: Greetings 2 | 3 | on: [pull_request, issues] 4 | 5 | jobs: 6 | greeting: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/first-interaction@v1 10 | with: 11 | repo-token: ${{ secrets.GITHUB_TOKEN }} 12 | pr-message: 'Hello @${{ github.actor }}, thank you for submitting a PR! We will respond as soon as possible.' 13 | issue-message: | 14 | Hello @${{ github.actor }}, thanks for contributing to the HiveMQ community! We will respond as soon as possible. 15 | 16 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | update_release_draft: 13 | permissions: 14 | contents: write 15 | pull-requests: write 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: release-drafter/release-drafter@v6.1.0 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "SendMessageOnLoop .NET Core Launch (console)", 6 | "type": "coreclr", 7 | "request": "launch", 8 | "preLaunchTask": "build SendMessageOnLoop", 9 | "program": "${workspaceFolder}/Examples/SendMessageOnLoop/bin/Debug/net8.0/SendMessageOnLoop.dll", 10 | "args": [], 11 | "cwd": "${workspaceFolder}", 12 | "stopAtEntry": false, 13 | "console": "internalConsole" 14 | }, 15 | { 16 | "name": ".NET Core Attach", 17 | "type": "coreclr", 18 | "request": "attach" 19 | }, 20 | { 21 | // Use IntelliSense to find out which attributes exist for C# debugging 22 | // Use hover for the description of the existing attributes 23 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 24 | "name": ".NET Core Launch (console)", 25 | "type": "coreclr", 26 | "request": "launch", 27 | "preLaunchTask": "build", 28 | // If you have changed target frameworks, make sure to update the program path. 29 | "program": "${workspaceFolder}/Tests/HiveMQtt.Test/bin/Debug/net8.0/HiveMQtt.Test.dll", 30 | "args": [], 31 | "cwd": "${workspaceFolder}/Tests/HiveMQtt.Test", 32 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 33 | "console": "integratedTerminal", 34 | "stopAtEntry": false 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.ignoreWords": [ 3 | "Unsub" 4 | ], 5 | "cSpell.words": [ 6 | "CONNACK", 7 | "hivemq", 8 | "hivemqtt", 9 | "PUBACK", 10 | "PUBCOMP", 11 | "PUBREC", 12 | "PUBREL", 13 | "SUBACK", 14 | "UNSUBACK", 15 | "Xunit" 16 | ], 17 | "dotnet.defaultSolution": "HiveMQtt.sln" 18 | } 19 | -------------------------------------------------------------------------------- /Benchmarks/ClientBenchmarkApp/ClientBenchmarkApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Benchmarks/ClientBenchmarkApp/Program.cs: -------------------------------------------------------------------------------- 1 | namespace ClientBenchmarkApp; 2 | 3 | using System; 4 | using BenchmarkDotNet.Attributes; 5 | using BenchmarkDotNet.Running; 6 | 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); 11 | } 12 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | latest 5 | true 6 | latest 7 | enable 8 | enable 9 | false 10 | 11 | 12 | 13 | Peter Giacomo Lombardo 14 | HiveMQ, GmbH 15 | Copyright © HiveMQ GmbH. All rights Reserved 16 | true 17 | Apache-2.0 18 | https://hivemq.github.io/hivemq-mqtt-client-dotnet/ 19 | Icon.png 20 | README.md 21 | https://github.com/hivemq/hivemq-mqtt-client-dotnet 22 | git 23 | 24 | The HiveMQtt release details are maintained in Github: 25 | https://github.com/hivemq/hivemq-mqtt-client-dotnet/releases 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | preview 6 | 10 | 11 | normal 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Documentation/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /Documentation/README.md: -------------------------------------------------------------------------------- 1 | # Documentation Portal 2 | 3 | The documentation portal for the HiveMQtt client is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. 4 | 5 | The API documentation is generated from the C# source code using docfx. 6 | 7 | ## DocFX 8 | 9 | ### Installation 10 | 11 | ``` 12 | $ dotnet tool install docfx 13 | ``` 14 | 15 | ### Generate API Metadata 16 | 17 | ``` 18 | dotnet tool run docfx metadata ./docfx.json 19 | ``` 20 | 21 | ### Generate API Documentation 22 | 23 | ``` 24 | $ dotnet tool run docfx build ./docfx.json 25 | ``` 26 | 27 | ## Docusaurus 28 | 29 | ### Installation 30 | 31 | ``` 32 | $ yarn 33 | ``` 34 | 35 | ### Local Development 36 | 37 | ``` 38 | $ yarn start 39 | ``` 40 | 41 | This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. 42 | 43 | ### Build 44 | 45 | ``` 46 | $ yarn build 47 | ``` 48 | 49 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 50 | 51 | ### Deployment 52 | 53 | ```yarn deploy``` 54 | 55 | Using SSH: 56 | 57 | ``` 58 | $ USE_SSH=true yarn deploy 59 | ``` 60 | 61 | Not using SSH: 62 | 63 | ``` 64 | $ GIT_USER= yarn deploy 65 | ``` 66 | 67 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 68 | -------------------------------------------------------------------------------- /Documentation/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /Documentation/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "src": "../", 7 | "files": [ 8 | "**/HiveMQtt.csproj" 9 | ] 10 | } 11 | ], 12 | "dest": ".metadata", 13 | "outputFormat": "markdown" 14 | } 15 | ], 16 | "build": { 17 | "markdownEngineName": "markdig", 18 | "content": [ 19 | { 20 | "src": ".metadata", 21 | "dest": ".", 22 | "files": [ 23 | "**/*.yml", 24 | "**/*.md" 25 | ], 26 | "exclude": [ 27 | "**/node_modules/**" 28 | ] 29 | } 30 | ], 31 | "resource": [ 32 | { 33 | "files": [] 34 | } 35 | ], 36 | "output": "api", 37 | "template": [ 38 | "default", 39 | "modern" 40 | ], 41 | "globalMetadata": { 42 | "_appName": "HiveMQtt", 43 | "_appTitle": "HiveMQtt", 44 | "_enableSearch": false, 45 | "pdf": false 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Documentation/docs/connecting.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 40 3 | --- 4 | 5 | # Connecting to an MQTT Broker 6 | 7 | ## with Defaults 8 | 9 | Without any options given, the `HiveMQClient` will search on `localhost` port 1883 for an unsecured broker. 10 | 11 | If you don't have a broker at this location, see the next sections. 12 | 13 | ```csharp 14 | using HiveMQtt.Client; 15 | 16 | // Connect 17 | var client = new HiveMQClient(); 18 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 19 | ``` 20 | 21 | ## With Specific Options 22 | 23 | The `HiveMQClientOptions` class provides a set of options that can be used to configure various aspects of the `HiveMQClient`. 24 | 25 | The easiest way to construct this class is to use `HiveMQClientOptionsBuilder`. 26 | 27 | ```csharp 28 | var options = new HiveMQClientOptionsBuilder(). 29 | WithBroker('candy.x39.eu.hivemq.cloud'). 30 | WithPort(8883). 31 | WithUseTLS(true). 32 | Build(); 33 | 34 | var client = new HiveMQClient(options); 35 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 36 | ``` 37 | 38 | ## With Automatic Reconnect 39 | 40 | ```csharp 41 | var options = new HiveMQClientOptionsBuilder(). 42 | WithBroker('candy.x39.eu.hivemq.cloud'). 43 | WithAutomaticReconnect(true) 44 | Build(); 45 | 46 | var client = new HiveMQClient(options); 47 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 48 | ``` 49 | 50 | ## Using WebSockets 51 | 52 | ```csharp 53 | var options = new HiveMQClientOptionsBuilder() 54 | .WithWebSocketServer("ws://broker.hivemq.com:8000/mqtt") 55 | .Build(); 56 | 57 | var client = new HiveMQClient(options); 58 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 59 | ``` 60 | 61 | ## Using an IP address 62 | 63 | Some embedded devices don't have DNS support and can only connect to static IPs. Here's how you can connect: 64 | 65 | ```csharp 66 | var options = new HiveMQClientOptionsBuilder() 67 | .WithBroker("10.0.12.222:8000") 68 | .Build(); 69 | 70 | var client = new HiveMQClient(options); 71 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 72 | ``` 73 | 74 | ## See Also 75 | 76 | * [HiveMQClientOptionsBuilder Reference](/docs/reference/client_options_builder) 77 | * [Automatic Reconnect](/docs/reference/automatic_reconnect) 78 | * [How to Set a Last Will & Testament](/docs/how-to/set-lwt) 79 | * [Connect with TLS but allow Invalid TLS Certificates](/docs/how-to/allow-invalid-certs) 80 | * [Securely Connect to a Broker with Basic Authentication Credentials](/docs/how-to/connect-with-auth) 81 | * [Custom Client Certificates](/docs/how-to/client-certificates) 82 | * [HiveMQClientOptionsBuilder.cs](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Source/HiveMQtt/Client/HiveMQClientOptionsBuilder.cs) 83 | -------------------------------------------------------------------------------- /Documentation/docs/events/Events.md: -------------------------------------------------------------------------------- 1 | # Lifecycle Events 2 | 3 | The HiveMQ client offers a comprehensive set of built-in lifecycle events that empower users to seamlessly integrate with every aspect of the client's operation. These events serve as hooks, enabling developers to customize behavior, closely monitor activity, and extend the functionality of the client to suit their specific requirements. 4 | 5 | By leveraging these events, developers can dynamically modify the client's behavior at various stages of its lifecycle. Whether it's intercepting incoming or outgoing messages, performing custom authentication or authorization logic, or implementing advanced monitoring and logging capabilities, the event system provides a powerful mechanism for fine-grained control and extensibility. 6 | 7 | These events cover a wide range of scenarios, including connection establishment and termination, message publishing and reception, subscription management, error handling, and more. By tapping into these events, developers can seamlessly integrate their own code and business logic into the client's workflow, enabling them to build robust and tailored MQTT applications that align perfectly with their unique use cases. 8 | -------------------------------------------------------------------------------- /Documentation/docs/events/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Lifecycle Events", 3 | "position": 70 4 | } 5 | -------------------------------------------------------------------------------- /Documentation/docs/help.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 100 3 | --- 4 | 5 | # Getting Help 6 | 7 | ## Community Forum 8 | 9 | Visit the [HiveMQ Community Forum](https://community.hivemq.com/) to engage with a vibrant community of users, developers, and experts. The forum is an excellent place to ask questions, share your experiences, and collaborate with others who use or contribute to HiveMQ. Explore existing topics, participate in discussions, and seek assistance from the community. 10 | 11 | ## GitHub Repository 12 | 13 | For technical issues, bug reports, or feature requests related to the HiveMQ MQTT Client for .NET, visit our [GitHub repository](https://github.com/hivemq/hivemq-mqtt-client-dotnet). You can open new issues, contribute to ongoing discussions, and submit pull requests. Our development team actively monitors the repository, and the GitHub platform serves as a collaborative space for the community. 14 | 15 | ## Professional Support 16 | 17 | If you require professional assistance or have specific support needs, consider reaching out to our [official support channels](https://www.hivemq.com/support/). Our support team is dedicated to helping you resolve issues, optimize your implementation, and ensure a smooth experience with HiveMQ. Explore the available support plans and choose the one that best suits your requirements. 18 | 19 | ## Additional Resources 20 | 21 | - [HiveMQ Website](https://www.hivemq.com/): Explore our official website for comprehensive information about HiveMQ, its features, and the MQTT protocol. 22 | - [Documentation](https://www.hivemq.com/docs/): Access detailed documentation to better understand HiveMQ's capabilities and configuration options. 23 | - [Blog](https://www.hivemq.com/blog/): Stay updated on the latest developments, best practices, and MQTT insights by reading our blog posts. 24 | 25 | For any other inquiries or general information, feel free to [contact us](https://www.hivemq.com/contact/). We value your engagement with the HiveMQ community and are here to assist you on your MQTT journey! 26 | 27 | -------------------------------------------------------------------------------- /Documentation/docs/how-to/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "How To Guides", 3 | "position": 80, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Guides on how to do almost anything with HiveMQtt." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Documentation/docs/how-to/allow-invalid-certs.md: -------------------------------------------------------------------------------- 1 | # Connecting with TLS and Allowing Invalid TLS Certificates 2 | 3 | In certain development or testing scenarios, you might need to connect to an MQTT broker that uses TLS but has an invalid or self-signed certificate. The HiveMQtt client library provides an option to disable the TLS certificate check upon connection, which can be useful in these situations. 4 | 5 | The `AllowInvalidBrokerCertificates` option in the `HiveMQClientOptions` class allows you to disable the TLS certificate check. 6 | 7 | Here's an example of how to use this option: 8 | 9 | ```csharp 10 | var options = new HiveMQClientOptionsBuilder() 11 | .WithBroker("broker-with-invalid-tls-cert.localhost.dev") 12 | .WithPort(8883) 13 | .WithUseTls(true) 14 | .WithAllowInvalidBrokerCertificates(true) 15 | .Build(); 16 | 17 | var client = new HiveMQClient(options); 18 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 19 | ``` 20 | 21 | In this example, we first create an instance of HiveMQClientOptionsBuilder. We then set the broker address, port, and enable TLS. The WithAllowInvalidBrokerCertificates(true) method call disables the TLS certificate check. Finally, we build the options and use them to create a new HiveMQClient. 22 | 23 | :::note 24 | 25 | Disabling the TLS certificate check can expose your application to security risks, such as man-in-the-middle attacks. Therefore, this option should only be used in controlled environments for development or testing purposes. 26 | 27 | ::: 28 | 29 | ## See Also 30 | 31 | * [HiveMQClientOptionsBuilder.cs](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Source/HiveMQtt/Client/HiveMQClientOptionsBuilder.cs) 32 | * [HiveMQClientOptions.cs](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Source/HiveMQtt/Client/Options/HiveMQClientOptions.cs) 33 | * [TLS/SSL - MQTT Security Fundamentals](https://www.hivemq.com/blog/mqtt-security-fundamentals-tls-ssl/) 34 | * [HiveMQ Documentation on Security](https://docs.hivemq.com/hivemq/latest/user-guide/security.html) 35 | -------------------------------------------------------------------------------- /Documentation/docs/how-to/connect-with-auth.md: -------------------------------------------------------------------------------- 1 | # Securely Connect to a Broker with Basic Authentication Credentials 2 | 3 | To securely connect to an MQTT Broker with basic authentication credentials, use the `UserName` and `Password` fields in `HiveMQClientOptions`: 4 | 5 | ```csharp 6 | var options = new HiveMQClientOptionsBuilder() 7 | .WithBroker("b273h09193b.s1.eu.hivemq.cloud") 8 | .WithPort(8883) 9 | .WithUseTls(true) 10 | .WithUserName("my-username") 11 | .WithPassword("my-password") 12 | .Build(); 13 | 14 | var client = new HiveMQClient(options); 15 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 16 | ``` 17 | 18 | ## See Also 19 | 20 | * [Authentication with Username and Password - MQTT Security Fundamentals](https://www.hivemq.com/blog/mqtt-security-fundamentals-authentication-username-password/) 21 | * [Advanced Authentication Mechanisms - MQTT Security Fundamentals](https://www.hivemq.com/blog/mqtt-security-fundamentals-advanced-authentication-mechanisms/) 22 | * [HiveMQ Cloud / Authentication and Authorization](https://docs.hivemq.com/hivemq-cloud/authn-authz.html) 23 | * [HiveMQClientOptionsBuilder.cs](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Source/HiveMQtt/Client/HiveMQClientOptionsBuilder.cs) 24 | * [HiveMQClientOptions.cs](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Source/HiveMQtt/Client/Options/HiveMQClientOptions.cs) 25 | -------------------------------------------------------------------------------- /Documentation/docs/how-to/debug.md: -------------------------------------------------------------------------------- 1 | # How to Debug 2 | 3 | When working with the HiveMQtt client, there may be instances where deeper insight into the internal workings of the client is necessary to troubleshoot or understand its behavior. One of the most effective ways to gain this insight is through TRACE level logging. 4 | 5 | # Understanding TRACE Level Logging 6 | 7 | TRACE level logging is the most detailed form of logging, providing comprehensive information about the events happening within the HiveMQtt client. Enabling TRACE logging allows you to see a fine-grained view of the client's operations, which can be invaluable for debugging complex issues. 8 | 9 | See [How to Configure Logging](/docs/how-to/configure-logging) for the specifics on how to enable TRACE logging. 10 | -------------------------------------------------------------------------------- /Documentation/docs/how-to/wait-on-event.md: -------------------------------------------------------------------------------- 1 | # Wait on an Event 2 | 3 | Use a `TaskCompletionSource` in your event handlers to wait for events to complete. 4 | 5 | ```csharp 6 | // The TaskCompletionSource setup 7 | var taskCompletionSource = new TaskCompletionSource(); 8 | 9 | // Event handler that sets the result of the `TaskCompletionSource` 10 | client.AfterDisconnect += (sender, args) => 11 | { 12 | // Do the AfterDisconnect work for your application 13 | // 14 | // Mark the taskCompletionSource as completed 15 | taskCompletionSource.SetResult(true); 16 | }; 17 | 18 | // Connect 19 | var result = await client.ConnectAsync().ConfigureAwait(false); 20 | 21 | // 22 | // Insert application work here... 23 | // 24 | 25 | // and Disconnect 26 | await client.DisconnectAsync().ConfigureAwait(false); 27 | 28 | // Wait for the AfterDisconnect event handler to finish 29 | // ...with a 5 second timeout as a hang safety 30 | await taskCompletionSource.Task.WaitAsync(TimeSpan.FromSeconds(5)).ConfigureAwait(false); 31 | ``` 32 | 33 | ## See Also 34 | 35 | * [Lifecycle Events](/docs/events) 36 | * [Events Source](https://github.com/hivemq/hivemq-mqtt-client-dotnet/tree/main/Source/HiveMQtt/Client/Events) 37 | * [TaskCompletionSource Class (System.Threading.Tasks)](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskcompletionsource-1?view=net-8.0) 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Documentation/docs/namespaces.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 30 3 | --- 4 | # Namespaces 5 | 6 | The HiveMQtt client is broken in to a few key namespaces that provides various functionality. This page serves as a reference to these namespaces and what they encapsulate. 7 | 8 | # Definition 9 | 10 | In C#, a namespace is a way to organize and group related classes, interfaces, structs, enums, and other types. It provides a hierarchical naming structure to avoid naming conflicts and to provide logical separation of code elements. Namespaces help in organizing code into logical units, improving code readability, and facilitating code reuse. 11 | 12 | # Example 13 | 14 | ```csharp 15 | using HiveMQtt.Client; 16 | using HiveMQtt.MQTT5.Types; 17 | 18 | /// code 19 | ``` 20 | 21 | # List of Namespaces 22 | 23 | 24 | | Namespace | Description | Classes | 25 | |-----------------------|----------|----------| 26 | | `HiveMQtt.Client` | Base namespace for the HiveMQClient and related classes. | `HiveMQClient`, `LastWillAndTestament`, etc...| 27 | | `HiveMQtt.Client.Options`| Class that encapsulate options. | `ConnectOptions`, `DisconnectOptions`, `SubscribeOptions` etc...| 28 | | `HiveMQtt.Client.Events` | Classes related to the event subsystem. | _See events reference._| 29 | | `HiveMQtt.Client.Exceptions` | HiveMQtt Exceptions. | `HiveMQttClientException` | 30 | | `HiveMQtt.Client.ReasonCodes` | Reason code exceptions. | `QoS1ReasonCode`, `QoS2ReasonCode`| 31 | | `HiveMQtt.Client.Results` | Result classes.| `ConnectResult`, `PublishResult`, `SubscribeResult`, `UnsubscribeResult`| 32 | | `HiveMQtt.MQTT5.Types` | MQTT protocol types.| `QualityOfService`, `RetainHandling`, `TopicFilter` etc...| 33 | | `HiveMQtt.MQTT5.Packets` | MQTT packet classes. | `ConnectPacket`, `PingReqPacket` etc...| 34 | | `HiveMQtt.MQTT5.ReasonCodes` | Packet level reason codes. | `ConnAckReasonCode`, `PubRecReasonCode`| 35 | -------------------------------------------------------------------------------- /Documentation/docs/reference/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Reference", 3 | "position": 85, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Comprehensive reference guide." 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Documentation/docs/reference/automatic_reconnect.md: -------------------------------------------------------------------------------- 1 | # Automatic Reconnect 2 | 3 | The HiveMQtt MQTT library provides an automatic reconnect functionality that allows the client to automatically reconnect to the MQTT broker in case of a disconnection. This feature is disabled by default. 4 | 5 | # Example 6 | 7 | ```csharp 8 | var options = new HiveMQClientOptionsBuilder() 9 | .WithAutomaticReconnect(true) 10 | .Build(); 11 | 12 | // Create a new client with the configured options 13 | var client = new HiveMQttClient(options); 14 | ``` 15 | 16 | # Backoff Strategy 17 | 18 | The automatic reconnect functionality uses a backoff strategy to attempt to reconnect to the MQTT broker periodically until success. The backoff strategy starts with a delay of 5 seconds and doubles the delay with each failed attempt, up to a maximum of 1 minute. 19 | 20 | # Maximum Attempts 21 | 22 | The backoff strategy will attempt to reconnect a maximum of once per minute. The client will attempt to reconnect indefinitely until successful. 23 | 24 | # Summary 25 | 26 | The automatic reconnect functionality a convenient way to handle disconnections from the MQTT broker. Users can also use the `OnConnect` event handler to add custom logic when the client successfully reconnects to the MQTT broker. 27 | -------------------------------------------------------------------------------- /Documentation/docs/reference/connect_options.md: -------------------------------------------------------------------------------- 1 | # ConnectOptions 2 | 3 | The `ConnectOptions` class provides options for a connect call made with `ConnectAsync`. These options can override settings that were originally set in `HiveMQClientOptions`. 4 | 5 | ## Constructors 6 | 7 | * `ConnectOptions()`: Initializes a new instance of the `ConnectOptions` class with defaults. 8 | 9 | ## Properties 10 | 11 | * `SessionExpiryInterval`: Gets or sets the session expiry interval in seconds. This overrides any value set in HiveMQClientOptions. 12 | + Example: `SessionExpiryInterval = 3600` sets the session to expire in 1 hour. 13 | 14 | * `KeepAlive`: Gets or sets the keep alive period in seconds. This overrides any value set in HiveMQClientOptions. 15 | + Example: `KeepAlive = 60` sets the keep alive to 60 seconds. 16 | 17 | * `CleanStart`: Gets or sets whether to use a clean start. This overrides any value set in HiveMQClientOptions. 18 | + Example: `CleanStart = true` starts a new session, discarding any existing session. 19 | 20 | ## Examples 21 | 22 | ```csharp 23 | ConnectOptions connectOptions = new ConnectOptions(); 24 | connectOptions.SessionExpiryInterval = 3600; // 1 hour session expiry 25 | connectOptions.KeepAlive = 60; // 60 second keep alive 26 | connectOptions.CleanStart = true; // Start with a clean session 27 | 28 | await client.ConnectAsync(connectOptions); 29 | ``` 30 | 31 | ## See Also 32 | 33 | * [HiveMQClientOptions Reference](/docs/reference/client_options) 34 | * [Connecting to an MQTT Broker](/docs/connecting) 35 | * [Session Handling](/docs/how-to/session-handling) 36 | -------------------------------------------------------------------------------- /Documentation/docs/reference/connect_options_builder.md: -------------------------------------------------------------------------------- 1 | # ConnectOptionsBuilder 2 | 3 | The `ConnectOptionsBuilder` class is a builder pattern implementation that provides a convenient way to construct `ConnectOptions` objects for configuring connect behavior in HiveMQtt client applications. 4 | 5 | ## Methods 6 | 7 | ### `WithSessionExpiryInterval(long sessionExpiryInterval)` 8 | 9 | Sets the session expiry interval for the connection. 10 | 11 | - **Description:** Specifies the duration, in seconds, for which the session state will be maintained by the broker. This overrides any value set in HiveMQClientOptions. 12 | - **Example:** 13 | ```csharp 14 | .WithSessionExpiryInterval(3600) // 1 hour session expiry 15 | ``` 16 | 17 | ### `WithKeepAlive(int keepAlive)` 18 | 19 | Sets the keep alive period for the connection. 20 | 21 | - **Description:** Specifies the maximum time interval that is permitted to elapse between the point at which the Client finishes transmitting one Control Packet and the point it starts sending the next. This overrides any value set in HiveMQClientOptions. 22 | - **Example:** 23 | ```csharp 24 | .WithKeepAlive(60) // 60 second keep alive 25 | ``` 26 | 27 | ### `WithCleanStart(bool cleanStart)` 28 | 29 | Sets whether to use a clean start for the connection. 30 | 31 | - **Description:** Specifies whether the Connection starts a new Session or is a continuation of an existing Session. This overrides any value set in HiveMQClientOptions. 32 | - **Example:** 33 | ```csharp 34 | .WithCleanStart(true) // Start with a clean session 35 | ``` 36 | 37 | ### `Build()` 38 | 39 | Builds the ConnectOptions instance. 40 | 41 | - **Description:** Creates and returns a new ConnectOptions object with all the configured settings. 42 | - **Example:** 43 | ```csharp 44 | ConnectOptions options = new ConnectOptionsBuilder() 45 | .WithSessionExpiryInterval(3600) 46 | .WithKeepAlive(60) 47 | .WithCleanStart(true) 48 | .Build(); 49 | ``` 50 | 51 | ## Complete Example 52 | 53 | ```csharp 54 | var connectOptions = new ConnectOptionsBuilder() 55 | .WithSessionExpiryInterval(3600) // 1 hour session expiry 56 | .WithKeepAlive(60) // 60 second keep alive 57 | .WithCleanStart(true) // Start with a clean session 58 | .Build(); 59 | 60 | await client.ConnectAsync(connectOptions); 61 | ``` 62 | 63 | ## See Also 64 | 65 | * [ConnectOptions Reference](/docs/reference/connect_options) 66 | * [HiveMQClientOptions Reference](/docs/reference/client_options) 67 | * [Connecting to an MQTT Broker](/docs/connecting) 68 | * [Session Handling](/docs/how-to/session-handling) 69 | -------------------------------------------------------------------------------- /Documentation/docs/reference/disconnect_options.md: -------------------------------------------------------------------------------- 1 | # DisconnectOptions 2 | 3 | The `DisconnectOptions` class provides options for a disconnect call made with `DisconnectAsync`. 4 | 5 | ## Constructors 6 | 7 | * `DisconnectOptions()`: Initializes a new instance of the `DisconnectOptions` class with defaults. 8 | 9 | ## Properties 10 | 11 | * `ReasonCode`: Gets or sets the reason code for the disconnection. The default value is `NormalDisconnection`. 12 | + Possible values are details in [DisconnectReasonCode enum](https://github.com/hivemq/hivemq-mqtt-client-dotnet/blob/main/Source/HiveMQtt/MQTT5/ReasonCodes/DisconnectReasonCode.cs). 13 | * `SessionExpiry`: Gets or sets the session expiry in seconds. This sets the expiration for the session to the indicated value. 14 | + Example: `SessionExpiry = 3600` sets the session to expire in 1 hour. 15 | * `ReasonString`: Gets or sets the reason string for the disconnection. This is a human-readable string used for diagnostics only. 16 | + Example: `ReasonString = "Device power save mode."` 17 | * `UserProperties`: Gets or sets the user properties for the disconnection. This is a dictionary of key-value pairs. 18 | + Example: `UserProperties = new Dictionary { { "device-id", "xrw02k-224a" }, { "TZ", "CEST" } }` sets the user properties to include in the disconnect call. 19 | 20 | ## Examples 21 | 22 | ```csharp 23 | DisconnectOptions disconnectOptions = new DisconnectOptions(); 24 | disconnectOptions.ReasonCode = DisconnectReasonCode.NormalDisconnection; 25 | disconnectOptions.SessionExpiry = 3600; 26 | disconnectOptions.ReasonString = "Device power save mode"; 27 | disconnectOptions.UserProperties = new Dictionary { { "device-id", "xrw02k-224a" }, { "TZ", "CEST" } }; 28 | 29 | await client.DisconnectAsync(disconnectOptions); 30 | ``` 31 | -------------------------------------------------------------------------------- /Documentation/docs/reference/subscribe_options.md: -------------------------------------------------------------------------------- 1 | 2 | # SubscribeOptions 3 | 4 | The `SubscribeOptions` class is used to define options for subscribing to topics in the HiveMQ MQTT client. It allows you to specify topic filters, user properties, subscription identifiers, and handlers for processing messages. 5 | 6 | ## Constructor 7 | 8 | ### SubscribeOptions() 9 | Initializes a new instance of the `SubscribeOptions` class. 10 | 11 | ```csharp 12 | SubscribeOptions(); 13 | ``` 14 | 15 | **Example**: 16 | ```csharp 17 | var options = new SubscribeOptions(); 18 | ``` 19 | 20 | --- 21 | 22 | ## Properties 23 | 24 | ### SubscriptionIdentifier 25 | Gets or sets the subscription identifier. 26 | 27 | ```csharp 28 | int? SubscriptionIdentifier { get; set; } 29 | ``` 30 | 31 | **Description**: 32 | A unique identifier for the subscription. 33 | 34 | **Example**: 35 | ```csharp 36 | options.SubscriptionIdentifier = 12345; 37 | ``` 38 | 39 | --- 40 | 41 | ### UserProperties 42 | Gets or sets the user properties for the subscription. 43 | 44 | ```csharp 45 | Dictionary UserProperties { get; set; } 46 | ``` 47 | 48 | **Description**: 49 | Custom key-value pairs for metadata associated with the subscription. 50 | 51 | **Example**: 52 | ```csharp 53 | options.UserProperties["key"] = "value"; 54 | ``` 55 | 56 | --- 57 | 58 | ### TopicFilters 59 | Gets or sets the topic filters for the subscription. 60 | 61 | ```csharp 62 | List TopicFilters { get; set; } 63 | ``` 64 | 65 | **Description**: 66 | Specifies the list of topic filters to subscribe to. 67 | 68 | **Example**: 69 | ```csharp 70 | options.TopicFilters.Add(new TopicFilter { Topic = "home/sensors/temperature", QoS = QualityOfService.AtLeastOnce }); 71 | ``` 72 | 73 | --- 74 | 75 | ### Handlers 76 | Gets or sets the handlers for message processing. 77 | 78 | ```csharp 79 | Dictionary> Handlers { get; set; } 80 | ``` 81 | 82 | **Description**: 83 | Defines per-topic message processing callbacks. The key is the topic filter, and the value is the handler function. 84 | 85 | **Example**: 86 | ```csharp 87 | options.Handlers["home/sensors/temperature"] = (sender, args) => 88 | { 89 | Console.WriteLine($"Received message: {args.Message.PayloadAsString}"); 90 | }; 91 | ``` 92 | 93 | --- 94 | 95 | ## Methods 96 | 97 | ### Validate() 98 | Validates the options for correctness. 99 | 100 | ```csharp 101 | void Validate(); 102 | ``` 103 | 104 | **Description**: 105 | Ensures that the `SubscribeOptions` instance contains at least one valid topic filter. 106 | 107 | **Exceptions**: 108 | - `HiveMQttClientException`: Thrown if no topic filters are specified. 109 | 110 | **Example**: 111 | ```csharp 112 | try 113 | { 114 | options.Validate(); 115 | } 116 | catch (HiveMQttClientException ex) 117 | { 118 | Console.WriteLine($"Validation failed: {ex.Message}"); 119 | } 120 | ``` 121 | 122 | -------------------------------------------------------------------------------- /Documentation/docs/reference/unsubscribe_options.md: -------------------------------------------------------------------------------- 1 | 2 | # UnsubscribeOptions 3 | 4 | The `UnsubscribeOptions` class defines the options for unsubscribing from topics in the HiveMQ MQTT client. This class allows you to specify the subscriptions to remove and include additional user properties for metadata. 5 | 6 | ## Constructor 7 | 8 | ### UnsubscribeOptions() 9 | Initializes a new instance of the `UnsubscribeOptions` class. 10 | 11 | ```csharp 12 | UnsubscribeOptions(); 13 | ``` 14 | 15 | **Example**: 16 | ```csharp 17 | var options = new UnsubscribeOptions(); 18 | ``` 19 | 20 | --- 21 | 22 | ## Properties 23 | 24 | ### Subscriptions 25 | Gets or sets the list of subscriptions for this unsubscribe operation. 26 | 27 | ```csharp 28 | List Subscriptions { get; set; } 29 | ``` 30 | 31 | **Description**: 32 | Specifies the topics and associated details to unsubscribe from. 33 | 34 | **Example**: 35 | ```csharp 36 | options.Subscriptions.Add(new Subscription("home/sensors/temperature", QualityOfService.AtLeastOnce)); 37 | ``` 38 | 39 | --- 40 | 41 | ### UserProperties 42 | Gets or sets the user properties for the unsubscribe operation. 43 | 44 | ```csharp 45 | Dictionary UserProperties { get; set; } 46 | ``` 47 | 48 | **Description**: 49 | Defines custom key-value pairs to include in the unsubscribe request. 50 | 51 | **Example**: 52 | ```csharp 53 | options.UserProperties["reason"] = "No longer needed"; 54 | ``` 55 | 56 | --- 57 | 58 | ## Methods 59 | 60 | ### Validate() 61 | Validates the options for correctness. 62 | 63 | ```csharp 64 | void Validate(); 65 | ``` 66 | 67 | **Description**: 68 | Ensures that the `UnsubscribeOptions` instance includes at least one valid subscription. 69 | 70 | **Exceptions**: 71 | - `HiveMQttClientException`: Thrown if no subscriptions are specified. 72 | 73 | **Example**: 74 | ```csharp 75 | try 76 | { 77 | options.Validate(); 78 | } 79 | catch (HiveMQttClientException ex) 80 | { 81 | Console.WriteLine($"Validation failed: {ex.Message}"); 82 | } 83 | ``` 84 | 85 | -------------------------------------------------------------------------------- /Documentation/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "documentation", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids" 15 | }, 16 | "dependencies": { 17 | "@docusaurus/core": "^3.0.1", 18 | "@docusaurus/preset-classic": "^3.0.1", 19 | "@mdx-js/react": "^3.0.0", 20 | "clsx": "^1.2.1", 21 | "prism-react-renderer": "^2.1.0", 22 | "react": "^18.0.0", 23 | "react-dom": "^18.0.0" 24 | }, 25 | "devDependencies": { 26 | "@docusaurus/module-type-aliases": "^3.0.1", 27 | "@docusaurus/types": "^3.0.1" 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.5%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 3 chrome version", 37 | "last 3 firefox version", 38 | "last 5 safari version" 39 | ] 40 | }, 41 | "engines": { 42 | "node": ">=18.0" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Documentation/sidebars.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creating a sidebar enables you to: 3 | - create an ordered group of docs 4 | - render a sidebar for each doc of that group 5 | - provide next/previous navigation 6 | 7 | The sidebars can be generated from the filesystem, or explicitly defined here. 8 | 9 | Create as many sidebars as you want. 10 | */ 11 | 12 | // @ts-check 13 | 14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 15 | const sidebars = { 16 | // By default, Docusaurus generates a sidebar from the docs folder structure 17 | docsSidebar: [{type: 'autogenerated', dirName: '.'}], 18 | 19 | // But you can create a sidebar manually 20 | /* 21 | docsSidebar: [ 22 | 'intro', 23 | 'hello', 24 | { 25 | type: 'category', 26 | label: 'Tutorial', 27 | items: ['tutorial-basics/create-a-document'], 28 | }, 29 | ], 30 | */ 31 | }; 32 | 33 | export default sidebars; 34 | -------------------------------------------------------------------------------- /Documentation/src/components/HomepageFeatures/index.js: -------------------------------------------------------------------------------- 1 | import Heading from '@theme/Heading'; 2 | import clsx from 'clsx'; 3 | import styles from './styles.module.css'; 4 | 5 | const FeatureList = [ 6 | { 7 | title: 'Easy to Use', 8 | image: 'img/easy-to-use.jpg', 9 | description: ( 10 | <> 11 | HiveMQ MQTT Client Libraries are designed to simplify the deployment and implementation of MQTT. 12 | 13 | ), 14 | }, 15 | { 16 | title: 'High Quality', 17 | image: 'img/high-quality.jpg', 18 | description: ( 19 | <> 20 | Supercharge your app development cycle by using high-quality, open-sourced MQTT Client Libraries to build IoT and IIoT applications quickly and easily. 21 | 22 | ), 23 | }, 24 | { 25 | title: 'Reliable', 26 | image: 'img/reliable.jpg', 27 | description: ( 28 | <> 29 | Built, tested, and maintained by dedicated, industry-leading IoT experts at HiveMQ. Minimize performance issues and outages by getting them from the source. 30 | 31 | ), 32 | }, 33 | ]; 34 | 35 | function Feature({image, title, description}) { 36 | return ( 37 |
38 |
39 | 40 |
41 |
42 | {title} 43 |

{description}

44 |
45 |
46 | ); 47 | } 48 | 49 | export default function HomepageFeatures() { 50 | return ( 51 |
52 |
53 |
54 | {FeatureList.map((props, idx) => ( 55 | 56 | ))} 57 |
58 |
59 |
60 | ); 61 | } 62 | -------------------------------------------------------------------------------- /Documentation/src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | -------------------------------------------------------------------------------- /Documentation/src/components/HomepageIntro/index.js: -------------------------------------------------------------------------------- 1 | import Heading from '@theme/Heading'; 2 | import clsx from 'clsx'; 3 | import styles from './styles.module.css'; 4 | 5 | export default function HomepageIntro() { 6 | return ( 7 |
8 |
9 |
10 |
11 |
12 |
13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /Documentation/src/components/HomepageIntro/styles.module.css: -------------------------------------------------------------------------------- 1 | 2 | .intro { 3 | display: flex; 4 | flex-direction: column; 5 | align-items: center; 6 | justify-content: center; 7 | padding: 0 1rem; 8 | text-align: center; 9 | margin: 0 auto; 10 | max-width: 800px; 11 | margin-bottom: 2rem; 12 | font-size:larger; 13 | font-style:italic; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Documentation/src/css/custom.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Any CSS included here will be global. The classic template 3 | * bundles Infima by default. Infima is a CSS framework designed to 4 | * work well for content-centric websites. 5 | */ 6 | 7 | /* You can override the default Infima variables here. */ 8 | :root { 9 | --ifm-color-primary: #302D36; 10 | --ifm-color-primary-dark: #e6a601; 11 | --ifm-color-primary-darker: #bf8f01; 12 | --ifm-color-primary-darkest: #997d00; 13 | --ifm-color-primary-light: #ffd31a; 14 | --ifm-color-primary-lighter: #ffe033; 15 | --ifm-color-primary-lightest: #ffea4d; 16 | --ifm-code-font-size: 95%; 17 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1); 18 | } 19 | 20 | 21 | /* For readability concerns, you should choose a lighter palette in dark mode. */ 22 | [data-theme='dark'] { 23 | --ifm-color-primary: #ddd; 24 | --ifm-color-primary-dark: #e6a601; 25 | --ifm-color-primary-darker: #bf8f01; 26 | --ifm-color-primary-darkest: #997d00; 27 | --ifm-color-primary-light: #ffd31a; 28 | --ifm-color-primary-lighter: #ffe033; 29 | --ifm-color-primary-lightest: #ffea4d; 30 | --ifm-code-font-size: 95%; 31 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1); 32 | } 33 | 34 | .hero__logo { 35 | height: 150px; 36 | } 37 | -------------------------------------------------------------------------------- /Documentation/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import Heading from '@theme/Heading'; 2 | import HomepageFeatures from '@site/src/components/HomepageFeatures'; 3 | import HomepageIntro from '@site/src/components/HomepageIntro'; 4 | import Layout from '@theme/Layout'; 5 | import Link from '@docusaurus/Link'; 6 | import clsx from 'clsx'; 7 | import styles from './index.module.css'; 8 | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; 9 | 10 | function HomepageHeader() { 11 | const {siteConfig} = useDocusaurusContext(); 12 | return ( 13 |
14 |
15 | HiveMQtt Logo 16 | HiveMQtt Logo 17 | HiveMQtt Logo 18 |
19 |
20 | ); 21 | } 22 | 23 | export default function Home() { 24 | const {siteConfig} = useDocusaurusContext(); 25 | return ( 26 | 28 | 29 |
30 | 31 | 32 |
33 |
34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /Documentation/src/pages/index.module.css: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS files with the .module.css suffix will be treated as CSS modules 3 | * and scoped locally. 4 | */ 5 | 6 | .heroBanner { 7 | padding: 4rem 0; 8 | text-align: center; 9 | position: relative; 10 | overflow: hidden; 11 | } 12 | 13 | @media screen and (max-width: 996px) { 14 | .heroBanner { 15 | padding: 2rem; 16 | } 17 | } 18 | 19 | .buttons { 20 | display: flex; 21 | align-items: center; 22 | justify-content: center; 23 | } 24 | -------------------------------------------------------------------------------- /Documentation/src/pages/markdown-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Markdown page example 3 | --- 4 | 5 | # Markdown page example 6 | 7 | You don't need React to write simple standalone pages. 8 | -------------------------------------------------------------------------------- /Documentation/static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hivemq/hivemq-mqtt-client-dotnet/b60b5c68d24658dde15b2e683a91220d7db35635/Documentation/static/.nojekyll -------------------------------------------------------------------------------- /Documentation/static/img/client-logo-two.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5b906c4e68f935e19e6ce1b0ed7b41d28665b8c1511fd42059f14caaa80015c0 3 | size 53230 4 | -------------------------------------------------------------------------------- /Documentation/static/img/client-logo.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:95f8794c0476bbd8d4bd53e8133b28cd1abc0ee54978d47063160d376212ad5b 3 | size 188992 4 | -------------------------------------------------------------------------------- /Documentation/static/img/csharp-logo.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f8e45e3c2310a51109a41401c6c3d8af7ec002fe4524c1204e25ddc6301246af 3 | size 115627 4 | -------------------------------------------------------------------------------- /Documentation/static/img/dotnet-bot_iot.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a80dba49b4bf8ad4341077a9ecd32b8a3f8686669162b8b4af127edfdd514953 3 | size 34799 4 | -------------------------------------------------------------------------------- /Documentation/static/img/dotnet-logo.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8fcf6f6cd575c0f8c643691765a7db2a4b3b104bfbff34646555f5ccffdb2895 3 | size 2140 4 | -------------------------------------------------------------------------------- /Documentation/static/img/easy-to-use.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a22dbb5ad6aa67e3ec51ceb806ae81063bf888587dab8041f65cfbf3e8d1286d 3 | size 219706 4 | -------------------------------------------------------------------------------- /Documentation/static/img/favicon.ico: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2bfb8852d4f97fa0c9e5475d5fa974c8ca59127043dde2dc3632f9422dc32536 3 | size 15406 4 | -------------------------------------------------------------------------------- /Documentation/static/img/high-quality.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d8906ee0b04ab9e244fb0432ded1f8ea3356ca2fd0eb7354f345579c6720e4cd 3 | size 215634 4 | -------------------------------------------------------------------------------- /Documentation/static/img/logo.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ca7c9d759fbd1f3e3a70881a42997aeaf48a9747f22d3444dc03f7fa2270e624 3 | size 20865 4 | -------------------------------------------------------------------------------- /Documentation/static/img/reliable.jpg: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d81063353952772bffd4d9eb051539db09358bcedecc6dae116e1769ef1d5546 3 | size 185080 4 | -------------------------------------------------------------------------------- /Documentation/static/public/bootstrap-icons-BNVXHMH5.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hivemq/hivemq-mqtt-client-dotnet/b60b5c68d24658dde15b2e683a91220d7db35635/Documentation/static/public/bootstrap-icons-BNVXHMH5.woff -------------------------------------------------------------------------------- /Documentation/static/public/bootstrap-icons-UDRIHJCM.woff2: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5b2dd4d4f81cd1f52a50b0833ea12c8f63f2c4ae4d2c5a799fcc741feb2ea40f 3 | size 130648 4 | -------------------------------------------------------------------------------- /Documentation/static/public/chunk-F7JJDB3C.min.js: -------------------------------------------------------------------------------- 1 | import{Ha as o,c as l}from"./chunk-YICCS3KT.min.js";import{d as c}from"./chunk-P42HNYSU.min.js";var i=c(l(),1);var x=(s,t)=>{let r=s.append("rect");if(r.attr("x",t.x),r.attr("y",t.y),r.attr("fill",t.fill),r.attr("stroke",t.stroke),r.attr("width",t.width),r.attr("height",t.height),t.rx!==void 0&&r.attr("rx",t.rx),t.ry!==void 0&&r.attr("ry",t.ry),t.attrs!==void 0)for(let e in t.attrs)r.attr(e,t.attrs[e]);return t.class!==void 0&&r.attr("class",t.class),r},h=(s,t)=>{let r={x:t.startx,y:t.starty,width:t.stopx-t.startx,height:t.stopy-t.starty,fill:t.fill,stroke:t.stroke,class:"rect"};x(s,r).lower()},y=(s,t)=>{let r=t.text.replace(o," "),e=s.append("text");e.attr("x",t.x),e.attr("y",t.y),e.attr("class","legend"),e.style("text-anchor",t.anchor),t.class!==void 0&&e.attr("class",t.class);let n=e.append("tspan");return n.attr("x",t.x+t.textMargin*2),n.text(r),e},p=(s,t,r,e)=>{let n=s.append("image");n.attr("x",t),n.attr("y",r);let a=(0,i.sanitizeUrl)(e);n.attr("xlink:href",a)},g=(s,t,r,e)=>{let n=s.append("use");n.attr("x",t),n.attr("y",r);let a=(0,i.sanitizeUrl)(e);n.attr("xlink:href",`#${a}`)},m=()=>({x:0,y:0,width:100,height:100,fill:"#EDF2AE",stroke:"#666",anchor:"start",rx:0,ry:0}),f=()=>({x:0,y:0,width:100,height:100,"text-anchor":"start",style:"#666",textMargin:0,rx:0,ry:0,tspan:!0});export{x as a,h as b,y as c,p as d,g as e,m as f,f as g}; 2 | //# sourceMappingURL=chunk-F7JJDB3C.min.js.map 3 | -------------------------------------------------------------------------------- /Documentation/static/public/chunk-P42HNYSU.min.js: -------------------------------------------------------------------------------- 1 | var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),o=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0})},l=(a,b,c,f)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&e(a,d,{get:()=>b[d],enumerable:!(f=h(b,d))||f.enumerable});return a};var p=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c,p as d}; 2 | //# sourceMappingURL=chunk-P42HNYSU.min.js.map 3 | -------------------------------------------------------------------------------- /Documentation/static/public/chunk-P42HNYSU.min.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /Documentation/static/public/flowDiagram-v2-2f8f667a-WVVXSXHH.min.js: -------------------------------------------------------------------------------- 1 | import{g as i,h as p}from"./chunk-U66T5BMR.min.js";import"./chunk-YAMJ4ASO.min.js";import{a as m,b as o}from"./chunk-I64Z623A.min.js";import"./chunk-3RELVOUY.min.js";import"./chunk-DALFUHAB.min.js";import"./chunk-EKFGDCJ4.min.js";import{J as l,b as a,c as s,kb as e}from"./chunk-YICCS3KT.min.js";import{d as t}from"./chunk-P42HNYSU.min.js";var g=t(a(),1),n=t(s(),1),c=t(l(),1);var y={parser:m,db:o,renderer:i,styles:p,init:r=>{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,e({flowchart:{arrowMarkerAbsolute:r.arrowMarkerAbsolute}}),i.setConf(r.flowchart),o.clear(),o.setGen("gen-2")}};export{y as diagram}; 2 | //# sourceMappingURL=flowDiagram-v2-2f8f667a-WVVXSXHH.min.js.map 3 | -------------------------------------------------------------------------------- /Documentation/static/public/flowDiagram-v2-2f8f667a-WVVXSXHH.min.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": ["../../node_modules/mermaid/dist/flowDiagram-v2-2f8f667a.js"], 4 | "sourcesContent": ["import { p as parser, f as flowDb } from \"./flowDb-170db09d.js\";\nimport { f as flowRendererV2, a as flowStyles } from \"./styles-b966c4ae.js\";\nimport { p as setConfig } from \"./mermaid-934d9bea.js\";\nimport \"d3\";\nimport \"dagre-d3-es/src/graphlib/index.js\";\nimport \"./index-67a42d7d.js\";\nimport \"dagre-d3-es/src/dagre/index.js\";\nimport \"dagre-d3-es/src/graphlib/json.js\";\nimport \"./edges-80f1ebb6.js\";\nimport \"./createText-aebacdfe.js\";\nimport \"mdast-util-from-markdown\";\nimport \"ts-dedent\";\nimport \"dagre-d3-es/src/dagre-js/label/add-html-label.js\";\nimport \"khroma\";\nimport \"dayjs\";\nimport \"@braintree/sanitize-url\";\nimport \"dompurify\";\nimport \"lodash-es/memoize.js\";\nimport \"lodash-es/merge.js\";\nimport \"stylis\";\nimport \"lodash-es/isEmpty.js\";\nconst diagram = {\n parser,\n db: flowDb,\n renderer: flowRendererV2,\n styles: flowStyles,\n init: (cnf) => {\n if (!cnf.flowchart) {\n cnf.flowchart = {};\n }\n cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;\n setConfig({ flowchart: { arrowMarkerAbsolute: cnf.arrowMarkerAbsolute } });\n flowRendererV2.setConf(cnf.flowchart);\n flowDb.clear();\n flowDb.setGen(\"gen-2\");\n }\n};\nexport {\n diagram\n};\n"], 5 | "mappings": "oVAcA,IAAAA,EAAO,SACPC,EAAO,SACPC,EAAO,SAKP,IAAMC,EAAU,CACd,OAAAC,EACA,GAAIC,EACJ,SAAUC,EACV,OAAQC,EACR,KAAOC,GAAQ,CACRA,EAAI,YACPA,EAAI,UAAY,CAAC,GAEnBA,EAAI,UAAU,oBAAsBA,EAAI,oBACxCC,EAAU,CAAE,UAAW,CAAE,oBAAqBD,EAAI,mBAAoB,CAAE,CAAC,EACzEF,EAAe,QAAQE,EAAI,SAAS,EACpCH,EAAO,MAAM,EACbA,EAAO,OAAO,OAAO,CACvB,CACF", 6 | "names": ["import_dayjs", "import_sanitize_url", "import_dompurify", "diagram", "parser$1", "flowDb", "flowRendererV2", "flowStyles", "cnf", "setConfig"] 7 | } 8 | -------------------------------------------------------------------------------- /Documentation/static/public/lunr.hy-XFQCAWFO.min.js: -------------------------------------------------------------------------------- 1 | import{b as o}from"./chunk-P42HNYSU.min.js";var s=o((i,r)=>{(function(e,t){typeof define=="function"&&define.amd?define(t):typeof i=="object"?r.exports=t():t()(e.lunr)})(i,function(){return function(e){if(typeof e>"u")throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(typeof e.stemmerSupport>"u")throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.hy=function(){this.pipeline.reset(),this.pipeline.add(e.hy.trimmer,e.hy.stopWordFilter)},e.hy.wordCharacters="[A-Za-z\u0530-\u058F\uFB00-\uFB4F]",e.hy.trimmer=e.trimmerSupport.generateTrimmer(e.hy.wordCharacters),e.Pipeline.registerFunction(e.hy.trimmer,"trimmer-hy"),e.hy.stopWordFilter=e.generateStopWordFilter("\u0564\u0578\u0582 \u0587 \u0565\u0584 \u0567\u056B\u0580 \u0567\u056B\u0584 \u0570\u0565\u057F\u0578 \u0576\u0561\u0587 \u0576\u0580\u0561\u0576\u0584 \u0578\u0580\u0568 \u057E\u0580\u0561 \u0567 \u0578\u0580 \u057A\u056B\u057F\u056B \u0565\u0576 \u0561\u0575\u057D \u0574\u0565\u057B \u0576 \u056B\u0580 \u0578\u0582 \u056B \u0561\u0575\u0564 \u0578\u0580\u0578\u0576\u0584 \u0561\u0575\u0576 \u056F\u0561\u0574 \u0567\u0580 \u0574\u056B \u0565\u057D \u0570\u0561\u0574\u0561\u0580 \u0561\u0575\u056C \u056B\u057D\u056F \u0567\u056B\u0576 \u0565\u0576\u0584 \u0570\u0565\u057F \u056B\u0576 \u0569 \u0567\u056B\u0576\u0584 \u0574\u0565\u0576\u0584 \u0576\u0580\u0561 \u0576\u0561 \u0564\u0578\u0582\u0584 \u0565\u0574 \u0567\u056B \u0568\u057D\u057F \u0578\u0580\u057A\u0565\u057D \u0578\u0582\u0574".split(" ")),e.Pipeline.registerFunction(e.hy.stopWordFilter,"stopWordFilter-hy"),e.hy.stemmer=function(){return function(t){return typeof t.update=="function"?t.update(function(n){return n}):t}}(),e.Pipeline.registerFunction(e.hy.stemmer,"stemmer-hy")}})});export default s(); 2 | /*! Bundled license information: 3 | 4 | lunr-languages/lunr.hy.js: 5 | (*! 6 | * Lunr languages, `Armenian` language 7 | * https://github.com/turbobit/lunr-languages 8 | * 9 | * Copyright 2021, Manikandan Venkatasubban 10 | * http://www.mozilla.org/MPL/ 11 | *) 12 | (*! 13 | * based on 14 | * Snowball JavaScript Library v0.3 15 | * http://code.google.com/p/urim/ 16 | * http://snowball.tartarus.org/ 17 | * 18 | * Copyright 2010, Oleg Mazko 19 | * http://www.mozilla.org/MPL/ 20 | *) 21 | */ 22 | //# sourceMappingURL=lunr.hy-XFQCAWFO.min.js.map 23 | -------------------------------------------------------------------------------- /Documentation/static/public/lunr.ja-6645DQV5.min.js: -------------------------------------------------------------------------------- 1 | import{a}from"./chunk-334IV3XH.min.js";import"./chunk-P42HNYSU.min.js";export default a(); 2 | //# sourceMappingURL=lunr.ja-6645DQV5.min.js.map 3 | -------------------------------------------------------------------------------- /Documentation/static/public/lunr.ja-6645DQV5.min.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": [], 4 | "sourcesContent": [], 5 | "mappings": "", 6 | "names": [] 7 | } 8 | -------------------------------------------------------------------------------- /Documentation/static/public/lunr.jp-2KRE2L63.min.js: -------------------------------------------------------------------------------- 1 | import{a as i}from"./chunk-334IV3XH.min.js";import{b as r}from"./chunk-P42HNYSU.min.js";var o=r((p,e)=>{e.exports=i()});export default o(); 2 | //# sourceMappingURL=lunr.jp-2KRE2L63.min.js.map 3 | -------------------------------------------------------------------------------- /Documentation/static/public/lunr.jp-2KRE2L63.min.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": ["../../node_modules/lunr-languages/lunr.jp.js"], 4 | "sourcesContent": ["// jp is the country code, while ja is the language code\n// a new lunr.ja.js has been created, but in order to\n// keep the backward compatibility, we'll leave the lunr.jp.js\n// here for a while, and just make it use the new lunr.ja.js\nmodule.exports = require('./lunr.ja');"], 5 | "mappings": "wFAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,CAIAA,EAAO,QAAU", 6 | "names": ["require_lunr_jp", "__commonJSMin", "exports", "module"] 7 | } 8 | -------------------------------------------------------------------------------- /Documentation/static/public/lunr.th-LSQ6T65I.min.js: -------------------------------------------------------------------------------- 1 | import{b as h}from"./chunk-P42HNYSU.min.js";var p=h((r,o)=>{(function(e,t){typeof define=="function"&&define.amd?define(t):typeof r=="object"?o.exports=t():t()(e.lunr)})(r,function(){return function(e){if(typeof e>"u")throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(typeof e.stemmerSupport>"u")throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var t=e.version[0]=="2";e.th=function(){this.pipeline.reset(),this.pipeline.add(e.th.trimmer),t?this.tokenizer=e.th.tokenizer:(e.tokenizer&&(e.tokenizer=e.th.tokenizer),this.tokenizerFn&&(this.tokenizerFn=e.th.tokenizer))},e.th.wordCharacters="[\u0E00-\u0E7F]",e.th.trimmer=e.trimmerSupport.generateTrimmer(e.th.wordCharacters),e.Pipeline.registerFunction(e.th.trimmer,"trimmer-th");var n=e.wordcut;n.init(),e.th.tokenizer=function(i){if(!arguments.length||i==null||i==null)return[];if(Array.isArray(i))return i.map(function(s){return t?new e.Token(s):s});var f=i.toString().replace(/^\s+/,"");return n.cut(f).split("|")}}})});export default p(); 2 | /*! Bundled license information: 3 | 4 | lunr-languages/lunr.th.js: 5 | (*! 6 | * Lunr languages, `Thai` language 7 | * https://github.com/MihaiValentin/lunr-languages 8 | * 9 | * Copyright 2017, Keerati Thiwanruk 10 | * http://www.mozilla.org/MPL/ 11 | *) 12 | (*! 13 | * based on 14 | * Snowball JavaScript Library v0.3 15 | * http://code.google.com/p/urim/ 16 | * http://snowball.tartarus.org/ 17 | * 18 | * Copyright 2010, Oleg Mazko 19 | * http://www.mozilla.org/MPL/ 20 | *) 21 | */ 22 | //# sourceMappingURL=lunr.th-LSQ6T65I.min.js.map 23 | -------------------------------------------------------------------------------- /Documentation/static/public/lunr.vi-S3VOAA5A.min.js: -------------------------------------------------------------------------------- 1 | import{b as u}from"./chunk-P42HNYSU.min.js";var o=u((t,r)=>{(function(e,i){typeof define=="function"&&define.amd?define(i):typeof t=="object"?r.exports=i():i()(e.lunr)})(t,function(){return function(e){if(typeof e>"u")throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(typeof e.stemmerSupport>"u")throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.vi=function(){this.pipeline.reset(),this.pipeline.add(e.vi.stopWordFilter,e.vi.trimmer)},e.vi.wordCharacters="[A-Za-z\u0300\u0350\u0301\u0351\u0309\u0323\u0303\u0343\xC2\xE2\xCA\xEA\xD4\xF4\u0102-\u0103\u0110-\u0111\u01A0-\u01A1\u01AF-\u01B0]",e.vi.trimmer=e.trimmerSupport.generateTrimmer(e.vi.wordCharacters),e.Pipeline.registerFunction(e.vi.trimmer,"trimmer-vi"),e.vi.stopWordFilter=e.generateStopWordFilter("l\xE0 c\xE1i nh\u01B0ng m\xE0".split(" "))}})});export default o(); 2 | /*! Bundled license information: 3 | 4 | lunr-languages/lunr.vi.js: 5 | (*! 6 | * Lunr languages, `Vietnamese` language 7 | * https://github.com/MihaiValentin/lunr-languages 8 | * 9 | * Copyright 2017, Keerati Thiwanruk 10 | * http://www.mozilla.org/MPL/ 11 | *) 12 | (*! 13 | * based on 14 | * Snowball JavaScript Library v0.3 15 | * http://code.google.com/p/urim/ 16 | * http://snowball.tartarus.org/ 17 | * 18 | * Copyright 2010, Oleg Mazko 19 | * http://www.mozilla.org/MPL/ 20 | *) 21 | */ 22 | //# sourceMappingURL=lunr.vi-S3VOAA5A.min.js.map 23 | -------------------------------------------------------------------------------- /Documentation/static/public/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hivemq/hivemq-mqtt-client-dotnet/b60b5c68d24658dde15b2e683a91220d7db35635/Documentation/static/public/main.css -------------------------------------------------------------------------------- /Documentation/static/public/main.js: -------------------------------------------------------------------------------- 1 | export default {} 2 | -------------------------------------------------------------------------------- /Documentation/static/public/mermaid.core-TOXYJXQE.min.js: -------------------------------------------------------------------------------- 1 | import{J as m,b as r,c as t,qb as p}from"./chunk-YICCS3KT.min.js";import{d as o}from"./chunk-P42HNYSU.min.js";var e=o(r(),1),f=o(t(),1);var l=o(m(),1);export{p as default}; 2 | //# sourceMappingURL=mermaid.core-TOXYJXQE.min.js.map 3 | -------------------------------------------------------------------------------- /Documentation/static/public/mermaid.core-TOXYJXQE.min.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "sources": ["../../node_modules/mermaid/dist/mermaid.core.mjs"], 4 | "sourcesContent": ["import \"ts-dedent\";\nimport { L } from \"./mermaid-934d9bea.js\";\nimport \"dayjs\";\nimport \"@braintree/sanitize-url\";\nimport \"d3\";\nimport \"dompurify\";\nimport \"khroma\";\nimport \"lodash-es/memoize.js\";\nimport \"lodash-es/merge.js\";\nimport \"stylis\";\nimport \"lodash-es/isEmpty.js\";\nexport {\n L as default\n};\n"], 5 | "mappings": "8GAEA,IAAAA,EAAO,SACPC,EAAO,SAEP,IAAAC,EAAO", 6 | "names": ["import_dayjs", "import_sanitize_url", "import_dompurify"] 7 | } 8 | -------------------------------------------------------------------------------- /Examples/ConnectReceiveAndPublish/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/net6.0/ConnectReceiveAndPublish.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "integratedTerminal", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach" 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /Examples/ConnectReceiveAndPublish/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/ConnectReceiveAndPublish.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/ConnectReceiveAndPublish.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/ConnectReceiveAndPublish.csproj" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /Examples/ConnectReceiveAndPublish/ConnectReceiveAndPublish.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Examples/ConnectReceiveAndPublish/README.md: -------------------------------------------------------------------------------- 1 | # ConnectReceiveAndPublish 2 | 3 | This example illustrates connecting to a broker with `CleanStart=false`. In this case, upon connecting, 4 | the broker will immediately send down any queued messages. This can be a large amount in some cases. 5 | 6 | For this reason, it's critical that the `OnMessageReceived` handler is configured before connecting to the broker. 7 | 8 | This example will connect to the broker with `CleanStart=false`, wait 10 seconds for any queued messages and 9 | then begin to publish Quality of Service Level 2 messages periodically. 10 | 11 | This example can be using in conjunction with `SendMessageOnLoop` to test `CleanStart` and handling queued 12 | messages. 13 | -------------------------------------------------------------------------------- /Examples/HiveMQtt-CLI/HiveMQtt-CLI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 25.0.1705.2 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HiveMQtt-CLI", "HiveMQtt-CLI\HiveMQtt-CLI.csproj", "{82B451A3-46B8-4097-A10A-DA4D08551A7D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {82B451A3-46B8-4097-A10A-DA4D08551A7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {82B451A3-46B8-4097-A10A-DA4D08551A7D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {82B451A3-46B8-4097-A10A-DA4D08551A7D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {82B451A3-46B8-4097-A10A-DA4D08551A7D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {DF0F5DEA-C733-41CE-9AFA-2388498D4268} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Examples/HiveMQtt-CLI/HiveMQtt-CLI/HiveMQtt-CLI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | HiveMQtt_CLI 7 | enable 8 | enable 9 | 10 | 11 | 12 | 4 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Examples/HiveMQtt-CLI/README.md: -------------------------------------------------------------------------------- 1 | # The Example HiveMQTT CLI 2 | 3 | This example is a demonstration on how to use the HiveMQtt NuGet package with a .NET console application. It was built using [Microsoft's console application template](https://aka.ms/new-console-template). See those instructions if you would like to expand the example further. 4 | 5 | The console application is ready to run after you specify the broker to connect to. See below for instructions. 6 | 7 | # Configure the broker to connect to 8 | 9 | Edit the `Program.cs` file and edit the `HiveMQClientOptions` to point to your MQTT broker. Bundled into that file are a few variations to potentially use. 10 | 11 | ```c# 12 | var options = new HiveMQClientOptions 13 | { 14 | Host = "b8212ae75b11f4y2abs254bdea608173b.s1.eu.hivemq.cloud", 15 | Port = 8883, 16 | UseTLS = true, 17 | UserName = 'myusername', 18 | Password = "mypassword', 19 | } 20 | ``` 21 | 22 | # How to build and run the application 23 | 24 | Change into the directory of the console application (where the `Program.cs` file is) and run `dotnet build` and `dotnet run`: 25 | 26 | ```bash 27 | cd Examples/HiveMQtt-CLI/HiveMQtt-CLI 28 | dotnet build 29 | dotnet run 30 | ``` 31 | 32 | # What does it do? 33 | 34 | The simple console application will connect to the specified broker, publish a quality of service level 2 message and disconnect. 35 | 36 | 37 | -------------------------------------------------------------------------------- /Examples/Logging/NLog.config: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Examples/Logging/README.md: -------------------------------------------------------------------------------- 1 | The HiveMQtt package uses [NLog](https://github.com/NLog/NLog) and can be configured with a configuration 2 | file (`NLog.config`). Having this file in the same directory of your executable will configure the 3 | HiveMQtt logger to output as configured. 4 | 5 | Use this file if you want to see the inner workings (Trace level to Error) of the HiveMQtt package in your application. 6 | 7 | See [this section](https://github.com/hivemq/hivemq-mqtt-client-dotnet#logging) in the repository README for more details. 8 | 9 | -------------------------------------------------------------------------------- /Examples/SendMessageOnLoop/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/bin/Debug/net6.0/SendMessageOnLoop.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "integratedTerminal", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | "name": ".NET Core Attach", 22 | "type": "coreclr", 23 | "request": "attach" 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /Examples/SendMessageOnLoop/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/SendMessageOnLoop.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/SendMessageOnLoop.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/SendMessageOnLoop.csproj" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /Examples/SendMessageOnLoop/README.md: -------------------------------------------------------------------------------- 1 | # SendMessageOnLoop 2 | 3 | This simple example program simply connects to the local broker and repeatedly sends Quality of Service 4 | level 2 messages to the broker. 5 | 6 | See the source code in `Program.cs` for details and options to configure the behavior. 7 | -------------------------------------------------------------------------------- /Examples/SendMessageOnLoop/SendMessageOnLoop.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Examples/SubscriberWithEvents/Program.cs: -------------------------------------------------------------------------------- 1 | namespace SubscriberWithEvents; 2 | 3 | using System.Text; 4 | using System.Text.Json; 5 | using HiveMQtt.Client; 6 | using HiveMQtt.Client.Options; 7 | using HiveMQtt.MQTT5.Types; 8 | 9 | public class Program 10 | { 11 | public static bool ExitRequested { get; set; } 12 | public static int MessageCount { get; set; } 13 | public static int PublishesReceivedCount { get; set; } 14 | 15 | public static async Task Main(string[] args) 16 | { 17 | MessageCount = 0; 18 | PublishesReceivedCount = 0; 19 | 20 | // Subscribe to the CancelKeyPress event 21 | Console.CancelKeyPress += (sender, e) => 22 | { 23 | // Handle Ctrl+C (SIGINT) by setting exitRequested flag 24 | e.Cancel = true; // Prevent process termination 25 | ExitRequested = true; 26 | Console.WriteLine("Ctrl+C (SIGINT) received. Press Ctrl+C again to exit immediately."); 27 | }; 28 | 29 | var options = new HiveMQClientOptions 30 | { 31 | Host = "127.0.0.1", 32 | Port = 1883, 33 | CleanStart = true, 34 | ClientId = "SubscriberWithEvents", 35 | }; 36 | 37 | var client = new HiveMQClient(options); 38 | 39 | // Message Handler 40 | // 41 | // It's important that this is setup before we connect to the broker 42 | // otherwise queued messages that are sent down may be lost. 43 | // 44 | client.OnMessageReceived += (sender, args) => 45 | { 46 | MessageCount++; 47 | }; 48 | 49 | // client.OnPublishReceived += (sender, args) => 50 | // { 51 | // PublishesReceivedCount++; 52 | // }; 53 | 54 | // Connect to the broker 55 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 56 | if (connectResult.ReasonCode != HiveMQtt.MQTT5.ReasonCodes.ConnAckReasonCode.Success) 57 | { 58 | throw new IOException($"Failed to connect: {connectResult.ReasonString}"); 59 | } 60 | 61 | // Subscribe to a topic 62 | var topic = "load/test/1"; 63 | var subscribeResult = await client.SubscribeAsync(topic, QualityOfService.ExactlyOnceDelivery).ConfigureAwait(false); 64 | Console.WriteLine($"Subscribed to {topic}: {subscribeResult.Subscriptions[0].SubscribeReasonCode}"); 65 | 66 | var message_number = 0; 67 | while (!ExitRequested) 68 | { 69 | await Task.Delay(1000).ConfigureAwait(false); 70 | Console.WriteLine($"Received {MessageCount} msgs/sec"); 71 | // Console.WriteLine($"Received {MessageCount} msgs/sec & {PublishesReceivedCount} publishes/sec"); 72 | MessageCount = 0; 73 | PublishesReceivedCount = 0; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Examples/SubscriberWithEvents/README.md: -------------------------------------------------------------------------------- 1 | # SubscriberWithEvents 2 | 3 | Example app that I used to measure subscription event processing. 4 | -------------------------------------------------------------------------------- /Examples/SubscriberWithEvents/SubscriberWithEvents.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /Images/Banner.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:66ca9fb26f248ad9c57eb3a1ab4a21d259ae11e016fd03ccfd6c2e3719f2f414 3 | size 6594 4 | -------------------------------------------------------------------------------- /Images/Hero.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cc5b249e74cd4aef00a6c73b89307b8bbf5378547fba318f60d50a8c3a359cc2 3 | size 11830 4 | -------------------------------------------------------------------------------- /Images/Icon.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:ca7c9d759fbd1f3e3a70881a42997aeaf48a9747f22d3444dc03f7fa2270e624 3 | size 20865 4 | -------------------------------------------------------------------------------- /Images/csharp-logo.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f0f7e9e6e70cf812dc9b152f58c7a26cfd14fa1fdc4368fd38b1d7a6b2f9fae0 3 | size 17484 4 | -------------------------------------------------------------------------------- /Images/hivemq-mqtt-client.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:559ef1a044ce653ca00c542695b81212b99b397eb83db5c19155736b62208119 3 | size 32951 4 | -------------------------------------------------------------------------------- /Source/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | true 7 | snupkg 8 | 9 | 10 | 11 | false 12 | ../../Key.snk 13 | 14 | 15 | 16 | 17 | true 18 | 19 | true 20 | 21 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | ./../../StyleCop.Analyzers.ruleset 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/ConnectOptionsbuilder.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client; 17 | 18 | using HiveMQtt.Client.Options; 19 | 20 | /// 21 | /// Builder class for the ConnectOptions class. 22 | /// 23 | public class ConnectOptionsBuilder 24 | { 25 | // private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); 26 | private readonly ConnectOptions options; 27 | 28 | public ConnectOptionsBuilder() => this.options = new ConnectOptions(); 29 | 30 | /// 31 | /// Sets the session expiry interval for the connect options. 32 | /// 33 | /// The session expiry interval in seconds. 34 | /// The ConnectOptionsBuilder instance. 35 | public ConnectOptionsBuilder WithSessionExpiryInterval(long sessionExpiryInterval) 36 | { 37 | this.options.SessionExpiryInterval = sessionExpiryInterval; 38 | return this; 39 | } 40 | 41 | /// 42 | /// Sets the keep alive for the connect options. 43 | /// 44 | /// The keep alive in seconds. 45 | /// The ConnectOptionsBuilder instance. 46 | public ConnectOptionsBuilder WithKeepAlive(int keepAlive) 47 | { 48 | this.options.KeepAlive = keepAlive; 49 | return this; 50 | } 51 | 52 | /// 53 | /// Sets the clean start for the connect options. 54 | /// 55 | /// The clean start flag. 56 | /// The ConnectOptionsBuilder instance. 57 | public ConnectOptionsBuilder WithCleanStart(bool cleanStart) 58 | { 59 | this.options.CleanStart = cleanStart; 60 | return this; 61 | } 62 | 63 | /// 64 | /// Builds the ConnectOptions instance. 65 | /// 66 | /// The ConnectOptions instance. 67 | public ConnectOptions Build() => this.options; 68 | } 69 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/AfterConnectEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.Client.Results; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called after a connect is sent to the broker. 23 | /// contains the result of the connect operation. 24 | /// 25 | public class AfterConnectEventArgs : EventArgs 26 | { 27 | public AfterConnectEventArgs(ConnectResult results) => this.ConnectResult = results; 28 | 29 | public ConnectResult ConnectResult { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/AfterDisconnectEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | /// 19 | /// Event arguments for the event. 20 | /// 21 | /// This event is called after a disconnect from the MQTT broker. This can be happen because 22 | /// of a call to or because of a failure. 23 | /// 24 | /// 25 | /// If the disconnect was caused by a call to , then 26 | /// will be true. If the disconnect 27 | /// was caused by a failure, then will be 28 | /// false. 29 | /// 30 | /// 31 | public class AfterDisconnectEventArgs : EventArgs 32 | { 33 | public AfterDisconnectEventArgs(bool clean = false) => this.CleanDisconnect = clean; 34 | 35 | public bool CleanDisconnect { get; set; } 36 | } 37 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/AfterSubscribeEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.Client.Results; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called after a subscribe is sent to the broker. 23 | /// contains the result of the subscribe operation. 24 | /// 25 | public class AfterSubscribeEventArgs : EventArgs 26 | { 27 | public AfterSubscribeEventArgs(SubscribeResult results) => this.SubscribeResult = results; 28 | 29 | public SubscribeResult SubscribeResult { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/AfterUnsubscribeEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.Client.Results; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called after a unsubscribe is sent to the broker. 23 | /// contains the result of the unsubscribe operation. 24 | /// 25 | public class AfterUnsubscribeEventArgs : EventArgs 26 | { 27 | public AfterUnsubscribeEventArgs(UnsubscribeResult results) => this.UnsubscribeResult = results; 28 | 29 | public UnsubscribeResult UnsubscribeResult { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/BeforeConnectEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.Client.Options; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called before a connect is sent to the broker. 23 | /// contains the options of the connect operation. 24 | /// 25 | public class BeforeConnectEventArgs : EventArgs 26 | { 27 | public BeforeConnectEventArgs(HiveMQClientOptions options) => this.Options = options; 28 | 29 | public HiveMQClientOptions Options { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/BeforeDisconnectEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | /// 19 | /// Event arguments for the event. 20 | /// This event is called before a disconnect is sent to the broker. 21 | /// 22 | public class BeforeDisconnectEventArgs : EventArgs 23 | { 24 | public BeforeDisconnectEventArgs() 25 | { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/BeforeSubscribeEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.Client.Options; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called before a subscribe is sent to the broker. 23 | /// contains the options of the subscribe operation. 24 | /// 25 | public class BeforeSubscribeEventArgs : EventArgs 26 | { 27 | public BeforeSubscribeEventArgs(SubscribeOptions options) => this.Options = options; 28 | 29 | public SubscribeOptions Options { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/BeforeUnsubscribeEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Types; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called before an unsubscribe is sent to the broker. 23 | /// contains the subscriptions to unsubscribe. 24 | /// 25 | public class BeforeUnsubscribeEventArgs : EventArgs 26 | { 27 | public BeforeUnsubscribeEventArgs(List subscriptions) => this.Subscriptions = subscriptions; 28 | 29 | public List Subscriptions { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnConnAckReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a CONNACK packet is received from the broker. 23 | /// contains the received CONNACK packet. 24 | /// 25 | public class OnConnAckReceivedEventArgs : EventArgs 26 | { 27 | public OnConnAckReceivedEventArgs(ConnAckPacket connAckPacket) => this.ConnAckPacket = connAckPacket; 28 | 29 | public ConnAckPacket ConnAckPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnConnectSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a CONNECT packet is sent to the broker. 23 | /// contains the sent CONNECT packet. 24 | /// 25 | public class OnConnectSentEventArgs : EventArgs 26 | { 27 | public OnConnectSentEventArgs(ConnectPacket connectPacket) => this.ConnectPacket = connectPacket; 28 | 29 | public ConnectPacket ConnectPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnDisconnectReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a DISCONNECT packet is received from the broker. 23 | /// contains the received DISCONNECT packet. 24 | /// 25 | public class OnDisconnectReceivedEventArgs : EventArgs 26 | { 27 | public OnDisconnectReceivedEventArgs(DisconnectPacket packet) => this.DisconnectPacket = packet; 28 | 29 | public DisconnectPacket DisconnectPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnDisconnectSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a DISCONNECT packet is sent to the broker. 23 | /// contains the sent DISCONNECT packet. 24 | /// 25 | public class OnDisconnectSentEventArgs : EventArgs 26 | { 27 | public OnDisconnectSentEventArgs(DisconnectPacket packet) => this.DisconnectPacket = packet; 28 | 29 | public DisconnectPacket DisconnectPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnMessageReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Types; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a message is received from the broker. 23 | /// contains the received message. 24 | /// 25 | public class OnMessageReceivedEventArgs : EventArgs 26 | { 27 | public OnMessageReceivedEventArgs(MQTT5PublishMessage message) => this.PublishMessage = message; 28 | 29 | public MQTT5PublishMessage PublishMessage { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPingReqSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PINGREQ packet is sent to the broker. 23 | /// contains the sent PINGREQ packet. 24 | /// 25 | public class OnPingReqSentEventArgs : EventArgs 26 | { 27 | public OnPingReqSentEventArgs(PingReqPacket pingReqPacket) => this.PingReqPacket = pingReqPacket; 28 | 29 | public PingReqPacket PingReqPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPingRespReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PINGRESP packet is received from the broker. 23 | /// contains the received PINGRESP packet. 24 | /// 25 | public class OnPingRespReceivedEventArgs : EventArgs 26 | { 27 | public OnPingRespReceivedEventArgs(PingRespPacket pingRespPacket) => this.PingRespPacket = pingRespPacket; 28 | 29 | public PingRespPacket PingRespPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPubAckReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBACK packet is received from the broker. 23 | /// contains the received PUBACK packet. 24 | /// 25 | public class OnPubAckReceivedEventArgs : EventArgs 26 | { 27 | public OnPubAckReceivedEventArgs(PubAckPacket pubAckPacket) => this.PubAckPacket = pubAckPacket; 28 | 29 | public PubAckPacket PubAckPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPubAckSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBACK packet is sent to the broker. 23 | /// contains the sent PUBACK packet. 24 | /// 25 | public class OnPubAckSentEventArgs : EventArgs 26 | { 27 | public OnPubAckSentEventArgs(PubAckPacket pubAckPacket) => this.PubAckPacket = pubAckPacket; 28 | 29 | public PubAckPacket PubAckPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPubCompReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBCOMP packet is received from the broker. 23 | /// contains the received PUBCOMP packet. 24 | /// 25 | public class OnPubCompReceivedEventArgs : EventArgs 26 | { 27 | public OnPubCompReceivedEventArgs(PubCompPacket pubCompPacket) => this.PubCompPacket = pubCompPacket; 28 | 29 | public PubCompPacket PubCompPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPubCompSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBCOMP packet is received from the broker. 23 | /// contains the received PUBCOMP packet. 24 | /// 25 | public class OnPubCompSentEventArgs : EventArgs 26 | { 27 | public OnPubCompSentEventArgs(PubCompPacket pubCompPacket) => this.PubCompPacket = pubCompPacket; 28 | 29 | public PubCompPacket PubCompPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPubRecReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBREC packet is received from the broker. 23 | /// contains the received PUBREC packet. 24 | /// 25 | public class OnPubRecReceivedEventArgs : EventArgs 26 | { 27 | public OnPubRecReceivedEventArgs(PubRecPacket pubRecPacket) => this.PubRecPacket = pubRecPacket; 28 | 29 | public PubRecPacket PubRecPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPubRecSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBREC packet is sent to the broker. 23 | /// contains the sent PUBREC packet. 24 | /// 25 | public class OnPubRecSentEventArgs : EventArgs 26 | { 27 | public OnPubRecSentEventArgs(PubRecPacket pubRecPacket) => this.PubRecPacket = pubRecPacket; 28 | 29 | public PubRecPacket PubRecPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPubRelReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBREL packet is received from the broker. 23 | /// contains the received PUBREL packet. 24 | /// 25 | public class OnPubRelReceivedEventArgs : EventArgs 26 | { 27 | public OnPubRelReceivedEventArgs(PubRelPacket pubRelPacket) => this.PubRelPacket = pubRelPacket; 28 | 29 | public PubRelPacket PubRelPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPubRelSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBREL packet is sent to the broker. 23 | /// contains the sent PUBREL packet. 24 | /// 25 | public class OnPubRelSentEventArgs : EventArgs 26 | { 27 | public OnPubRelSentEventArgs(PubRelPacket pubRelPacket) => this.PubRelPacket = pubRelPacket; 28 | 29 | public PubRelPacket PubRelPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPublishQoS1CompleteEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a QoS level 1 publish as been completed. 23 | /// contains the received PUBACK packet. 24 | /// 25 | public class OnPublishQoS1CompleteEventArgs : EventArgs 26 | { 27 | public OnPublishQoS1CompleteEventArgs(PubAckPacket packet) => this.PubAckPacket = packet; 28 | 29 | public PubAckPacket PubAckPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPublishQoS2CompleteEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5; 19 | using HiveMQtt.MQTT5.Packets; 20 | 21 | /// 22 | /// Event arguments for the event. 23 | /// This event is called when a QoS level 2 publish as been completed. 24 | /// contains the list of 25 | /// packets sent/received in the QoS 2 transaction chain. 26 | /// 27 | public class OnPublishQoS2CompleteEventArgs : EventArgs 28 | { 29 | public OnPublishQoS2CompleteEventArgs(List packetList) => this.PacketList = packetList; 30 | 31 | public List PacketList { get; set; } 32 | } 33 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPublishReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBLISH packet is received from the broker. 23 | /// contains the received PUBLISH packet. 24 | /// 25 | public class OnPublishReceivedEventArgs : EventArgs 26 | { 27 | public OnPublishReceivedEventArgs(PublishPacket publishPacket) => this.PublishPacket = publishPacket; 28 | 29 | public PublishPacket PublishPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnPublishSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a PUBLISH packet is sent to the broker. 23 | /// contains the sent PUBLISH packet. 24 | /// 25 | public class OnPublishSentEventArgs : EventArgs 26 | { 27 | public OnPublishSentEventArgs(PublishPacket publishPacket) => this.PublishPacket = publishPacket; 28 | 29 | public PublishPacket PublishPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnSubAckReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a SUBACK packet is received from the broker. 23 | /// contains the received SUBACK packet. 24 | /// 25 | public class OnSubAckReceivedEventArgs : EventArgs 26 | { 27 | public OnSubAckReceivedEventArgs(SubAckPacket subAckPacket) => this.SubAckPacket = subAckPacket; 28 | 29 | public SubAckPacket SubAckPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnSubscribeSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a SUBSCRIBE packet is sent to the broker. 23 | /// contains the sent SUBSCRIBE packet. 24 | /// 25 | public class OnSubscribeSentEventArgs : EventArgs 26 | { 27 | public OnSubscribeSentEventArgs(SubscribePacket subscribePacket) => this.SubscribePacket = subscribePacket; 28 | 29 | public SubscribePacket SubscribePacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnUnsubAckReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a UNSUBACK packet is received from the broker. 23 | /// contains the received UNSUBACK packet. 24 | /// 25 | public class OnUnsubAckReceivedEventArgs : EventArgs 26 | { 27 | public OnUnsubAckReceivedEventArgs(UnsubAckPacket unsubAckPacket) => this.UnsubAckPacket = unsubAckPacket; 28 | 29 | public UnsubAckPacket UnsubAckPacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Events/OnUnsubscribeSentEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Events; 17 | 18 | using HiveMQtt.MQTT5.Packets; 19 | 20 | /// 21 | /// Event arguments for the event. 22 | /// This event is called when a UNSUBSCRIBE packet is sent to the broker. 23 | /// contains the sent UNSUBSCRIBE packet. 24 | /// 25 | public class OnUnsubscribeSentEventArgs : EventArgs 26 | { 27 | public OnUnsubscribeSentEventArgs(UnsubscribePacket subscribePacket) => this.UnsubscribePacket = subscribePacket; 28 | 29 | public UnsubscribePacket UnsubscribePacket { get; set; } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Exceptions/HiveMQttClientException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Exceptions; 17 | 18 | using System.Runtime.Serialization; 19 | 20 | [Serializable] 21 | 22 | public class 23 | HiveMQttClientException : Exception 24 | { 25 | protected HiveMQttClientException(SerializationInfo info, StreamingContext context) 26 | { 27 | } 28 | 29 | public HiveMQttClientException() 30 | { 31 | } 32 | 33 | public HiveMQttClientException(string message) 34 | : base(message) 35 | { 36 | } 37 | 38 | public HiveMQttClientException(string message, Exception inner) 39 | : base(message, inner) 40 | { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Options/ConnectOptions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Options; 17 | 18 | /// 19 | /// The options class for a Connect call. The settings here can override the settings that may have 20 | /// been set in the HiveMQClientOptions. 21 | /// 22 | public class ConnectOptions 23 | { 24 | public long? SessionExpiryInterval { get; set; } 25 | 26 | public int? KeepAlive { get; set; } 27 | 28 | public bool? CleanStart { get; set; } 29 | } 30 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Options/SubscribeOptions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Options; 17 | 18 | using HiveMQtt.Client.Events; 19 | using HiveMQtt.Client.Exceptions; 20 | using HiveMQtt.MQTT5.Types; 21 | 22 | public class SubscribeOptions 23 | { 24 | public SubscribeOptions() 25 | { 26 | this.UserProperties = new Dictionary(); 27 | this.TopicFilters = new List(); 28 | } 29 | 30 | /// 31 | /// Gets or sets the Subscription Identifier. 32 | /// 33 | public int? SubscriptionIdentifier { get; set; } 34 | 35 | /// 36 | /// Gets or sets the User Properties for this subscribe. 37 | /// 38 | public Dictionary UserProperties { get; set; } 39 | 40 | /// 41 | /// Gets or sets the Topic Filters for this subscribe. 42 | /// 43 | public List TopicFilters { get; set; } 44 | 45 | /// 46 | /// Gets or sets the handlers for this subscribe. 47 | /// 48 | /// Per subscription callbacks can be registered here. The key is the topic filter 49 | /// and the value is the handler. If the topic string isn't found in one of the 50 | /// List<TopicFilters>, the handler will not be registered for that subscription. 51 | /// 52 | /// 53 | public Dictionary> Handlers { get; set; } = new(); 54 | 55 | /// 56 | /// Validate that the options in this instance are valid. 57 | /// 58 | /// The exception raised if some value is out of range or invalid. 59 | public void Validate() 60 | { 61 | if (this.TopicFilters.Count == 0) 62 | { 63 | throw new HiveMQttClientException("At least one topic filter must be specified for SubscribeOptions."); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Options/UnsubscribeOptions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Options; 17 | 18 | using HiveMQtt.Client.Exceptions; 19 | using HiveMQtt.MQTT5.Types; 20 | 21 | public class UnsubscribeOptions 22 | { 23 | public UnsubscribeOptions() 24 | { 25 | this.Subscriptions = new List(); 26 | this.UserProperties = new Dictionary(); 27 | } 28 | 29 | /// 30 | /// Gets or sets the Subscriptions for this unsubscribe. 31 | /// 32 | public List Subscriptions { get; set; } 33 | 34 | /// 35 | /// Gets or sets the User Properties for this unsubscribe. 36 | /// 37 | public Dictionary UserProperties { get; set; } 38 | 39 | /// 40 | /// Validate that the options in this instance are valid. 41 | /// 42 | /// Raises this exception if the options are invalid. 43 | public void Validate() 44 | { 45 | if (this.Subscriptions.Count == 0) 46 | { 47 | throw new HiveMQttClientException("At least one topic filter must be specified for UnsubscribeOptions."); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/ReasonCodes/QoS1ReasonCode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.ReasonCodes; 17 | 18 | using HiveMQtt.Client.Results; 19 | using HiveMQtt.MQTT5.ReasonCodes; 20 | 21 | /// 22 | /// Reason codes for QoS 1 publishes. 23 | /// 24 | /// This is a helper enum for the class. The reason codes in here 25 | /// are the same as and duplicate of the reason codes in . 26 | /// 27 | /// 28 | public enum QoS1ReasonCode 29 | { 30 | /// 31 | /// The message is accepted. Publication of the QoS 1 message proceeds. 32 | /// 33 | Success = 0x0, 34 | 35 | /// 36 | /// The message is accepted but there are no subscribers. This is sent only by the Server. 37 | /// If the Server knows that there are no matching subscribers, it MAY use this Reason Code instead of 0x00 (Success). 38 | /// 39 | NoMatchingSubscribers = 0x10, 40 | 41 | /// 42 | /// The receiver does not accept the publish but either does not want to reveal the reason, or it does not match one of the other values. 43 | /// 44 | UnspecifiedError = 0x80, 45 | 46 | /// 47 | /// The PUBLISH is valid but the receiver is not willing to accept it. 48 | /// 49 | ImplementationSpecificError = 0x83, 50 | 51 | /// 52 | /// The PUBLISH is not authorized. 53 | /// 54 | NotAuthorized = 0x87, 55 | 56 | /// 57 | /// The Topic Name is not malformed, but is not accepted by this Client or Server. 58 | /// 59 | TopicNameInvalid = 0x90, 60 | 61 | /// 62 | /// The Packet Identifier is already in use. This might indicate a mismatch in the Session State between the Client and Server. 63 | /// 64 | PacketIdentifierInUse = 0x91, 65 | 66 | /// 67 | /// An implementation or administrative imposed limit has been exceeded. 68 | /// 69 | QuotaExceeded = 0x97, 70 | 71 | /// 72 | /// The payload format does not match the one specified by the payload format indicator. 73 | /// 74 | PayloadFormatInvalid = 0x99, 75 | } 76 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/ReasonCodes/QoS2ReasonCode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.ReasonCodes; 17 | 18 | using HiveMQtt.Client.Results; 19 | using HiveMQtt.MQTT5.ReasonCodes; 20 | 21 | /// 22 | /// Reason codes for QoS 2 publishes. 23 | /// 24 | /// This is a helper enum for the class. The reason codes in here 25 | /// are the same as and duplicate of the reason codes in . 26 | /// 27 | /// 28 | public enum QoS2ReasonCode 29 | { 30 | /// 31 | /// The message is accepted. Publication of the QoS 2 message proceeds. 32 | /// 33 | Success = 0x00, 34 | 35 | /// 36 | /// The message is accepted but there are no subscribers. This is sent only by the Server. 37 | /// If the Server knows that there are no matching subscribers, it MAY use this Reason Code instead of 0x00 (Success). 38 | /// 39 | NoMatchingSubscribers = 0x10, 40 | 41 | /// 42 | /// The receiver does not accept the publish but either does not want to reveal the reason, or it does not match one of the other values. 43 | /// 44 | UnspecifiedError = 0x80, 45 | 46 | /// 47 | /// The PUBLISH is valid but the receiver is not willing to accept it. 48 | /// 49 | ImplementationSpecificError = 0x83, 50 | 51 | /// 52 | /// The PUBLISH is not authorized. 53 | /// 54 | NotAuthorized = 0x87, 55 | 56 | /// 57 | /// The Topic Name is not malformed, but is not accepted by this Server. 58 | /// 59 | TopicNameInvalid = 0x90, 60 | 61 | /// 62 | /// The Packet Identifier is already in use. This might indicate a mismatch in the Session State between the Client and Server. 63 | /// 64 | PacketIdentifierInUse = 0x91, 65 | 66 | /// 67 | /// An implementation or administrative imposed limit has been exceeded. 68 | /// 69 | QuotaExceeded = 0x97, 70 | 71 | /// 72 | /// The payload format does not match the one specified by the payload format indicator. 73 | /// 74 | PayloadFormatInvalid = 0x99, 75 | } 76 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Results/UnsubscribeResult.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Results; 17 | 18 | using HiveMQtt.MQTT5.Types; 19 | 20 | public class UnsubscribeResult 21 | { 22 | public UnsubscribeResult() => this.Subscriptions = new List(); 23 | 24 | public List Subscriptions { get; set; } 25 | } 26 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/Transport/TransportReadResult.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Transport; 17 | 18 | using System.Buffers; 19 | 20 | public class TransportReadResult 21 | { 22 | public bool Failed { get; set; } 23 | 24 | public ReadOnlySequence Buffer { get; set; } 25 | 26 | public TransportReadResult(ReadOnlySequence buffer) 27 | { 28 | this.Failed = false; 29 | this.Buffer = buffer; 30 | } 31 | 32 | public TransportReadResult(bool failed) 33 | { 34 | this.Failed = failed; 35 | this.Buffer = default; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Client/internal/ConnectState.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.Client.Internal; 17 | 18 | /// 19 | /// The state of the MQTT connection. 20 | /// 21 | internal enum ConnectState 22 | { 23 | /// 24 | /// The connection is being established. 25 | /// 26 | Connecting = 0x00, 27 | 28 | /// 29 | /// The connection is established. 30 | /// 31 | Connected = 0x01, 32 | 33 | /// 34 | /// The connection is being disconnected. 35 | /// 36 | Disconnecting = 0x02, 37 | 38 | /// 39 | /// The connection is disconnected. 40 | /// 41 | Disconnected = 0x03, 42 | } 43 | -------------------------------------------------------------------------------- /Source/HiveMQtt/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is used by Code Analysis to maintain SuppressMessage 2 | // attributes that are applied to this project. 3 | // Project-level suppressions either have no target or are given 4 | // a specific target and scoped to a namespace, type, member, etc. 5 | 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | [assembly: SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "Event handlers are not awaited and have no return.", Scope = "member", Target = "~M:HiveMQtt.Client.HiveMQClient.AutomaticReconnectHandler(System.Object,HiveMQtt.Client.Events.AfterDisconnectEventArgs)")] 9 | -------------------------------------------------------------------------------- /Source/HiveMQtt/HiveMQtt.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 25.0.1704.5 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HiveMQtt", "HiveMQtt.csproj", "{7A86FFD4-6CD2-419C-B8E8-53437CDB1E8B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {7A86FFD4-6CD2-419C-B8E8-53437CDB1E8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7A86FFD4-6CD2-419C-B8E8-53437CDB1E8B}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7A86FFD4-6CD2-419C-B8E8-53437CDB1E8B}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7A86FFD4-6CD2-419C-B8E8-53437CDB1E8B}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {B7404198-178C-43C5-9136-4BF25D23EC7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {B7404198-178C-43C5-9136-4BF25D23EC7E}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {B7404198-178C-43C5-9136-4BF25D23EC7E}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {B7404198-178C-43C5-9136-4BF25D23EC7E}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {FE0AD218-169C-4DE6-ADBE-0B55695620B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {FE0AD218-169C-4DE6-ADBE-0B55695620B4}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {FE0AD218-169C-4DE6-ADBE-0B55695620B4}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {FE0AD218-169C-4DE6-ADBE-0B55695620B4}.Release|Any CPU.Build.0 = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(SolutionProperties) = preSolution 28 | HideSolutionNode = FALSE 29 | EndGlobalSection 30 | GlobalSection(ExtensibilityGlobals) = postSolution 31 | SolutionGuid = {D8250CF7-F883-4013-ACC2-98259E17E6F9} 32 | EndGlobalSection 33 | EndGlobal 34 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Exceptions/MQTTProtocolException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Exceptions; 17 | 18 | using System; 19 | 20 | public class MQTTProtocolException : ArgumentException 21 | { 22 | public MQTTProtocolException() 23 | { 24 | } 25 | 26 | public MQTTProtocolException(string message) 27 | : base(message) 28 | { 29 | } 30 | 31 | public MQTTProtocolException(string message, Exception inner) 32 | : base(message, inner) 33 | { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Exceptions/MalformedVBIException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Exceptions; 17 | 18 | using System; 19 | 20 | public class MalformedVBIException : ArgumentException 21 | { 22 | public MalformedVBIException() 23 | { 24 | } 25 | 26 | // public MalformedVBIException(byte[] bytes) 27 | // : base(String.Format("Malformed VBI: {0}", bytes)) 28 | // { 29 | // } 30 | } 31 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/MalformedPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5; 17 | 18 | using System.Buffers; 19 | 20 | /// 21 | /// A packet with bad or nonsensical data. 22 | /// 23 | internal class MalformedPacket : ControlPacket 24 | { 25 | #pragma warning disable IDE0052 26 | private readonly ReadOnlySequence packetData; 27 | #pragma warning restore IDE0052 28 | 29 | public MalformedPacket(ReadOnlySequence buffer) => this.packetData = buffer; 30 | 31 | public override ControlPacketType ControlPacketType => ControlPacketType.Reserved; 32 | } 33 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Packets/AuthPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Packets/ConnAckPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Packets; 17 | 18 | using System.Buffers; 19 | using HiveMQtt.MQTT5.ReasonCodes; 20 | 21 | /// 22 | /// An MQTT Connect Control Packet as defined in: 23 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901074. 24 | /// 25 | public class ConnAckPacket : ControlPacket 26 | { 27 | public ConnAckPacket(ReadOnlySequence packetData) 28 | { 29 | this.SessionPresent = false; 30 | this.Decode(packetData); 31 | } 32 | 33 | public bool SessionPresent { get; set; } 34 | 35 | public int AckFlags { get; set; } 36 | 37 | public ConnAckReasonCode ReasonCode { get; set; } 38 | 39 | public override ControlPacketType ControlPacketType => ControlPacketType.ConnAck; 40 | 41 | /// 42 | /// Decode the received MQTT ConnAck packet. 43 | /// 44 | /// The raw packet data off the wire. 45 | public void Decode(ReadOnlySequence packetData) 46 | { 47 | var reader = new SequenceReader(packetData); 48 | this.PacketSize = packetData.Length; 49 | 50 | // The first byte is the MQTT Control Packet type and flags. 51 | reader.Advance(1); 52 | 53 | // The second byte is the Remaining Length 54 | var fhRemainingLength = DecodeVariableByteInteger(ref reader, out var vbiLength); 55 | 56 | if (reader.TryRead(out var ackFlags)) 57 | { 58 | this.SessionPresent = (ackFlags & 0x1) == 0x1; 59 | } 60 | 61 | if (reader.TryRead(out var reasonCode)) 62 | { 63 | this.ReasonCode = (ConnAckReasonCode)reasonCode; 64 | } 65 | 66 | var propertyLength = DecodeVariableByteInteger(ref reader); 67 | _ = this.DecodeProperties(ref reader, propertyLength); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Packets/PartialPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Packets; 17 | 18 | /// 19 | /// Part of a Control Packet. Used when not all of the data has yet arrived 20 | /// over the broker connection. 21 | /// 22 | internal class PartialPacket : ControlPacket 23 | { 24 | public override ControlPacketType ControlPacketType => ControlPacketType.Reserved; 25 | } 26 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Packets/PingReqPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Packets; 17 | 18 | using System.IO; 19 | 20 | /// 21 | /// An MQTT PingReq Control Packet. 22 | /// 23 | /// See also 24 | /// PingReq Control Packet. 25 | /// 26 | public class PingReqPacket : ControlPacket 27 | { 28 | public override ControlPacketType ControlPacketType => ControlPacketType.PingResp; 29 | 30 | /// 31 | /// Encode this packet to be sent on the wire. 32 | /// 33 | /// An array of bytes ready to be sent. 34 | public static byte[] Encode() 35 | { 36 | using (var stream = new MemoryStream(2)) 37 | { 38 | // Fixed Header 39 | stream.WriteByte(((byte)ControlPacketType.PingReq) << 4); 40 | stream.WriteByte(0x0); 41 | 42 | return stream.ToArray(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Packets/PingRespPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Packets; 17 | 18 | using System; 19 | 20 | /// 21 | /// An MQTT PingResp Control Packet. 22 | /// 23 | /// See also 24 | /// PingResp Control Packet. 25 | /// 26 | public class PingRespPacket : ControlPacket 27 | { 28 | public PingRespPacket() => this.ReceivedOn = DateTime.UtcNow; 29 | 30 | public override ControlPacketType ControlPacketType => ControlPacketType.PingResp; 31 | } 32 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Packets/SubAckPacket.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Packets; 17 | 18 | using System.Buffers; 19 | using HiveMQtt.MQTT5.ReasonCodes; 20 | 21 | /// 22 | /// An MQTT SUBACK Control Packet as defined in: 23 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901187. 24 | /// 25 | public class SubAckPacket : ControlPacket 26 | { 27 | public SubAckPacket(ReadOnlySequence packetData) 28 | { 29 | this.ReasonCodes = new List(); 30 | this.Decode(packetData); 31 | } 32 | 33 | /// 34 | /// Gets or sets the list of Reason Codes. 35 | /// 36 | public List ReasonCodes { get; set; } 37 | 38 | /// 39 | public override ControlPacketType ControlPacketType => ControlPacketType.SubAck; 40 | 41 | /// 42 | /// Decodes the raw packet data of a SUBACK packet. 43 | /// 44 | /// The raw packet data. 45 | public void Decode(ReadOnlySequence packetData) 46 | { 47 | var reader = new SequenceReader(packetData); 48 | this.PacketSize = packetData.Length; 49 | 50 | // Skip past the fixed header MQTT Control Packet type 51 | reader.Advance(1); 52 | 53 | // Remaining Length 54 | var fhRemainingLength = DecodeVariableByteInteger(ref reader, out var vbiLength); 55 | var variableHeaderStart = reader.Consumed; 56 | 57 | this.PacketIdentifier = (ushort)DecodePacketIdentifier(ref reader); 58 | 59 | var propertyLength = DecodeVariableByteInteger(ref reader, out var lengthOfPropertyLength); 60 | if (propertyLength > 0) 61 | { 62 | this.DecodeProperties(ref reader, propertyLength); 63 | } 64 | 65 | // Payload 66 | var variableHeaderLength = reader.Consumed - variableHeaderStart; 67 | var payloadLength = fhRemainingLength - variableHeaderLength; 68 | 69 | // The Payload contains a list of Reason Codes. 70 | for (var x = 0; x < payloadLength; x++) 71 | { 72 | reader.TryRead(out var reasonCode); 73 | this.ReasonCodes.Add((SubAckReasonCode)reasonCode); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/ReasonCodes/AuthReasonCode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.ReasonCodes; 17 | 18 | /// 19 | /// MQTT v5.0 AUTH Reason Codes as defined in: 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901220. 21 | /// 22 | public enum AuthReasonCode 23 | { 24 | /// 25 | /// Authentication is successful. 26 | /// 27 | Success = 0x00, 28 | 29 | /// 30 | /// Continue the authentication with another step. 31 | /// 32 | ContinueAuthentication = 0x18, 33 | 34 | /// 35 | /// Initiate a re-authentication. 36 | /// 37 | ReAuthenticate = 0x19, 38 | } 39 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/ReasonCodes/PubAckReasonCode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.ReasonCodes; 17 | 18 | /// 19 | /// MQTT v5.0 PUBACK Reason Codes as defined in: 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901121. 21 | /// 22 | public enum PubAckReasonCode 23 | { 24 | /// 25 | /// The message is accepted. Publication of the QoS 1 message proceeds. 26 | /// 27 | Success = 0x0, 28 | 29 | /// 30 | /// The message is accepted but there are no subscribers. This is sent only by the Server. 31 | /// If the Server knows that there are no matching subscribers, it MAY use this Reason Code instead of 0x00 (Success). 32 | /// 33 | NoMatchingSubscribers = 0x10, 34 | 35 | /// 36 | /// The receiver does not accept the publish but either does not want to reveal the reason, or it does not match one of the other values. 37 | /// 38 | UnspecifiedError = 0x80, 39 | 40 | /// 41 | /// The PUBLISH is valid but the receiver is not willing to accept it. 42 | /// 43 | ImplementationSpecificError = 0x83, 44 | 45 | /// 46 | /// The PUBLISH is not authorized. 47 | /// 48 | NotAuthorized = 0x87, 49 | 50 | /// 51 | /// The Topic Name is not malformed, but is not accepted by this Client or Server. 52 | /// 53 | TopicNameInvalid = 0x90, 54 | 55 | /// 56 | /// The Packet Identifier is already in use. This might indicate a mismatch in the Session State between the Client and Server. 57 | /// 58 | PacketIdentifierInUse = 0x91, 59 | 60 | /// 61 | /// An implementation or administrative imposed limit has been exceeded. 62 | /// 63 | QuotaExceeded = 0x97, 64 | 65 | /// 66 | /// The payload format does not match the one specified by the payload format indicator. 67 | /// 68 | PayloadFormatInvalid = 0x99, 69 | } 70 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/ReasonCodes/PubCompReasonCode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.ReasonCodes; 17 | 18 | /// 19 | /// MQTT v5.0 PUBCOMP Reason Codes as defined in: 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901154. 21 | /// 22 | public enum PubCompReasonCode 23 | { 24 | /// 25 | /// Message released. 26 | /// 27 | Success = 0x00, 28 | 29 | /// 30 | /// The Packet Identifier is not known. This is not an error during recovery, but at other times 31 | /// indicates a mismatch between the Session State on the Client and Server. 32 | /// 33 | PacketIdentifierNotFound = 0x92, 34 | } 35 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/ReasonCodes/PubRecReasonCode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.ReasonCodes; 17 | 18 | /// 19 | /// MQTT v5.0 PUBREC Reason Codes as defined in: 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901134. 21 | /// 22 | public enum PubRecReasonCode 23 | { 24 | /// 25 | /// The message is accepted. Publication of the QoS 2 message proceeds. 26 | /// 27 | Success = 0x00, 28 | 29 | /// 30 | /// The message is accepted but there are no subscribers. This is sent only by the Server. 31 | /// If the Server knows that there are no matching subscribers, it MAY use this Reason Code instead of 0x00 (Success). 32 | /// 33 | NoMatchingSubscribers = 0x10, 34 | 35 | /// 36 | /// The receiver does not accept the publish but either does not want to reveal the reason, or it does not match one of the other values. 37 | /// 38 | UnspecifiedError = 0x80, 39 | 40 | /// 41 | /// The PUBLISH is valid but the receiver is not willing to accept it. 42 | /// 43 | ImplementationSpecificError = 0x83, 44 | 45 | /// 46 | /// The PUBLISH is not authorized. 47 | /// 48 | NotAuthorized = 0x87, 49 | 50 | /// 51 | /// The Topic Name is not malformed, but is not accepted by this Server. 52 | /// 53 | TopicNameInvalid = 0x90, 54 | 55 | /// 56 | /// The Packet Identifier is already in use. This might indicate a mismatch in the Session State between the Client and Server. 57 | /// 58 | PacketIdentifierInUse = 0x91, 59 | 60 | /// 61 | /// An implementation or administrative imposed limit has been exceeded. 62 | /// 63 | QuotaExceeded = 0x97, 64 | 65 | /// 66 | /// The payload format does not match the one specified by the payload format indicator. 67 | /// 68 | PayloadFormatInvalid = 0x99, 69 | } 70 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/ReasonCodes/PubRelReasonCode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.ReasonCodes; 17 | 18 | /// 19 | /// MQTT v5.0 PUBREL Reason Codes as defined in: 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901144. 21 | /// 22 | public enum PubRelReasonCode 23 | { 24 | /// 25 | /// Message released. 26 | /// 27 | Success = 0x00, 28 | 29 | /// 30 | /// The Packet Identifier is not known. This is not an error during recovery, but at other times 31 | /// indicates a mismatch between the Session State on the Client and Server. 32 | /// 33 | PacketIdentifierNotFound = 0x92, 34 | } 35 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/ReasonCodes/UnsubAckReasonCode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.ReasonCodes; 17 | 18 | /// 19 | /// MQTT v5.0 UNSUBACK Reason Codes as defined in: 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901194. 21 | /// 22 | public enum UnsubAckReasonCode 23 | { 24 | /// 25 | /// The subscription is deleted. 26 | /// 27 | Success = 0x0, 28 | 29 | /// 30 | /// No matching Topic Filter is being used by the Client. 31 | /// 32 | NoSubscriptionExisted = 0x11, 33 | 34 | /// 35 | /// The unsubscribe could not be completed and the Server either does not wish to reveal the reason or none of the other Reason Codes apply. 36 | /// 37 | UnspecifiedError = 0x80, 38 | 39 | /// 40 | /// The UNSUBSCRIBE is valid but the Server does not accept it. 41 | /// 42 | ImplementationSpecificError = 0x83, 43 | 44 | /// 45 | /// The Client is not authorized to unsubscribe. 46 | /// 47 | NotAuthorized = 0x87, 48 | 49 | /// 50 | /// The Topic Filter is correctly formed but is not allowed for this Client. 51 | /// 52 | TopicFilterInvalid = 0x8F, 53 | 54 | /// 55 | /// The specified Packet Identifier is already in use. 56 | /// 57 | PacketIdentifierInUse = 0x91, 58 | } 59 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/ControlPacketType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5; 17 | 18 | /// 19 | /// MQTT v5.0 Control Packet Types as defined in 2.1.2 MQTT Control Packet type: 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901022. 21 | /// 22 | public enum ControlPacketType 23 | { 24 | /// 25 | /// Reserved. 26 | /// 27 | Reserved = 0x0, 28 | 29 | /// 30 | /// Connection Request. 31 | /// 32 | Connect = 0x1, 33 | 34 | /// 35 | /// Connect Acknowledgement. 36 | /// 37 | ConnAck = 0x2, 38 | 39 | /// 40 | /// Publish Message. 41 | /// 42 | Publish = 0x3, 43 | 44 | /// 45 | /// Publish Acknowledgement (QoS 1). 46 | /// 47 | PubAck = 0x4, 48 | 49 | /// 50 | /// Publish Received (QoS 2 delivery party 1). 51 | /// 52 | PubRec = 0x5, 53 | 54 | /// 55 | /// Publish Release (QoS 2 delivery party 2). 56 | /// 57 | PubRel = 0x6, 58 | 59 | /// 60 | /// Publish Complete(QoS 2 delivery party 3). 61 | /// 62 | PubComp = 0x7, 63 | 64 | /// 65 | /// Subscribe Request. 66 | /// 67 | Subscribe = 0x8, 68 | 69 | /// 70 | /// Subscribe Acknowledgement. 71 | /// 72 | SubAck = 0x9, 73 | 74 | /// 75 | /// Unsubscribe Request. 76 | /// 77 | Unsubscribe = 0xa, 78 | 79 | /// 80 | /// Unsubscribe Acknowledgement. 81 | /// 82 | UnsubAck = 0xb, 83 | 84 | /// 85 | /// PING Request. 86 | /// 87 | PingReq = 0xc, 88 | 89 | /// 90 | /// PING Response. 91 | /// 92 | PingResp = 0xd, 93 | 94 | /// 95 | /// Disconnect Notification. 96 | /// 97 | Disconnect = 0xe, 98 | 99 | /// 100 | /// Authentication Exchange. 101 | /// 102 | Auth = 0xf, 103 | } 104 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/MQTT5DataType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Types; 17 | 18 | /// 19 | /// MQTT v5.0 PropertyType as defined in 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901027. 21 | /// 22 | public enum MQTT5DataType 23 | { 24 | /// 25 | /// Property is a Byte. 26 | /// 27 | Byte = 0x0, 28 | 29 | /// 30 | /// Property is a Two Byte Integer. 31 | /// 32 | TwoByteInteger = 0x1, 33 | 34 | /// 35 | /// Property is a Four Byte Integer. 36 | /// 37 | FourByteInteger = 0x2, 38 | 39 | /// 40 | /// Property is a UTF-8 encoded string. 41 | /// 42 | UTF8EncodedString = 0x3, 43 | 44 | /// 45 | /// Property is a UTF-8 encoded string pair. 46 | /// 47 | UTF8EncodedStringPair = 0x4, 48 | 49 | /// 50 | /// Property is Binary Data. 51 | /// 52 | BinaryData = 0x5, 53 | 54 | /// 55 | /// Property is Variable Byte Integer. 56 | /// 57 | VariableByteInteger = 0x6, 58 | } 59 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/MQTT5LastWillProperties.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Types; 17 | 18 | /// 19 | /// MQTT version 5 properties as defined in 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901027. 21 | /// 22 | internal class MQTT5LastWillProperties 23 | { 24 | public MQTT5LastWillProperties() => this.UserProperties = new Dictionary(); 25 | 26 | public uint? WillDelayInterval { get; set; } 27 | 28 | public byte? PayloadFormatIndicator { get; set; } 29 | 30 | public uint? MessageExpiryInterval { get; set; } 31 | 32 | public string? ContentType { get; set; } 33 | 34 | public string? ResponseTopic { get; set; } 35 | 36 | public byte[]? CorrelationData { get; set; } 37 | 38 | /// 39 | /// Gets or sets a Dictionary containing the User Properties to be sent with the Last Will and Testament message. 40 | /// 41 | public Dictionary UserProperties { get; set; } 42 | } 43 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/MQTT5PayloadFormatIndicator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Types; 17 | 18 | /// 19 | /// MQTT v5 Payload Format Indicator. 20 | /// 21 | public enum MQTT5PayloadFormatIndicator 22 | { 23 | /// 24 | /// Indicates that the Payload is unspecified bytes, which is equivalent to not sending a Payload Format Indicator. 25 | /// 26 | Unspecified = 0, 27 | 28 | /// 29 | /// Indicates that the Payload is UTF-8 Encoded Character Data. The UTF-8 data in the Payload MUST be well-formed 30 | /// UTF-8 as defined by the Unicode specification [Unicode] and restated in RFC 3629 [RFC3629]. 31 | /// 32 | UTF8Encoded = 1, 33 | } 34 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/MQTT5Property.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Types; 17 | 18 | public class MQTT5Property 19 | { 20 | public int ID { get; set; } 21 | 22 | public MQTT5DataType DataType { get; set; } 23 | 24 | public byte? ByteValue { get; set; } 25 | 26 | public byte[]? TwoByteValue { get; set; } 27 | 28 | public byte[]? FourByteValue { get; set; } 29 | 30 | public byte[]? BinaryDataValue { get; set; } 31 | 32 | public string? UTF8EncodedStringValue { get; set; } 33 | 34 | public string? UTF8EncodedStringPairValue { get; set; } 35 | } 36 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/QualityOfService.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Types; 17 | 18 | /// 19 | /// MQTT delivers Application Messages according to the Quality of Service (QoS) levels defined in the following sections. 20 | /// 21 | public enum QualityOfService 22 | { 23 | /// 24 | /// The message is delivered according to the capabilities of the underlying network. 25 | /// The message arrives at the receiver either once or not at all. 26 | /// 27 | /// 28 | /// AKA: Fire and forget. 29 | /// 30 | /// 31 | AtMostOnceDelivery = 0x0, 32 | 33 | /// 34 | /// Ensures that the message arrives at the receiver at least once. 35 | /// 36 | AtLeastOnceDelivery = 0x1, 37 | 38 | /// 39 | /// The highest Quality of Service level, for use when neither loss nor duplication of messages are acceptable. 40 | /// 41 | ExactlyOnceDelivery = 0x2, 42 | } 43 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/RetainHandling.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Types; 17 | 18 | /// 19 | /// Defines the Retain Handling options for a subscription as defined in 20 | /// the 21 | /// MQTT Specification. 22 | /// 23 | public enum RetainHandling 24 | { 25 | /// 26 | /// Send retained messages at the time of the subscribe. 27 | /// 28 | SendAtSubscribe = 0x0, 29 | 30 | /// 31 | /// Send retained messages at subscribe only if the subscription does not currently exist. 32 | /// 33 | SendAtSubscribeIfNewSubscription = 0x1, 34 | 35 | /// 36 | /// Do not send retained messages at the time of the subscribe. 37 | /// 38 | DoNotSendAtSubscribe = 0x2, 39 | } 40 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/Subscription.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-present HiveMQ and the HiveMQ Community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | namespace HiveMQtt.MQTT5.Types; 17 | 18 | using HiveMQtt.Client.Events; 19 | using HiveMQtt.MQTT5.ReasonCodes; 20 | 21 | public class Subscription 22 | { 23 | public Subscription(TopicFilter topicFilter) => this.TopicFilter = topicFilter; 24 | 25 | public Subscription(string topicFilter) => this.TopicFilter = new TopicFilter(topicFilter); 26 | 27 | /// 28 | /// Gets the topic filter for the subscription. 29 | /// 30 | public TopicFilter TopicFilter { get; } 31 | 32 | /// 33 | /// Gets or sets the message handler for the subscription. 34 | /// 35 | public EventHandler? MessageReceivedHandler { get; set; } 36 | 37 | /// 38 | /// Gets or sets the reason code (result) for the subscribe call. 39 | /// 40 | /// See SubAckReasonCode or the 41 | /// 42 | /// MQTT specification for more information. 43 | /// 44 | /// 45 | public SubAckReasonCode SubscribeReasonCode { get; set; } 46 | 47 | /// 48 | /// Gets or sets the reason code (result) for the unsubscribe call. 49 | /// 50 | /// See UnsubAckReasonCode or the 51 | /// 52 | /// MQTT specification for more information. 53 | /// 54 | /// 55 | public UnsubAckReasonCode UnsubscribeReasonCode { get; set; } 56 | } 57 | -------------------------------------------------------------------------------- /Source/HiveMQtt/MQTT5/Types/VariableByteInteger.cs: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------- 2 | // Copyright 2023-present HiveMQ and the HiveMQ Community 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // -------------------------------------------------------------------------- 16 | namespace HiveMQtt.MQTT5.Types; 17 | 18 | /// 19 | /// Representation of a Variable Byte Integer as defined in: 20 | /// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901011. 21 | /// 22 | public class VariableByteInteger 23 | { 24 | /// 25 | /// Gets or sets the value of this variable byte integer. 26 | /// 27 | public int Value { get; set; } 28 | 29 | /// 30 | /// Gets or sets the length in bytes that this variable byte integer consumes when encoded. 31 | /// 32 | public int Length { get; set; } 33 | } 34 | -------------------------------------------------------------------------------- /Source/HiveMQtt/NLog.config: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 14 | 15 | 16 | 21 | 22 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Source/HiveMQtt/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("HiveMQtt.Test")] 4 | 5 | [assembly: CLSCompliant(true)] 6 | -------------------------------------------------------------------------------- /Tests/.editorconfig: -------------------------------------------------------------------------------- 1 | ########################################## 2 | # StyleCop 3 | ########################################## 4 | 5 | [*] 6 | # SA0001: XML comment analysis is disabled due to project configuration 7 | # Justification: Comments turned off 8 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA0001.md 9 | dotnet_diagnostic.SA0001.severity = none 10 | 11 | [*.cs] 12 | # SA1600: A C# code element is missing a documentation header. 13 | # Justification: Comments turned off 14 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1600.md 15 | dotnet_diagnostic.SA1600.severity = none 16 | 17 | # SA1601: A C# partial element is missing a documentation header. 18 | # Justification: Comments turned off 19 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1601.md 20 | dotnet_diagnostic.SA1601.severity = none 21 | 22 | # SA1602: An item within a C# enumeration is missing an XML documentation header. 23 | # Justification: Comments turned off 24 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1602.md 25 | dotnet_diagnostic.SA1602.severity = none 26 | 27 | ########################################## 28 | # Custom 29 | ########################################## 30 | 31 | [*.cs] 32 | # CA1062: Validate arguments of public methods 33 | # Justification: xUnit Theory method parameters don't need to be validated 34 | # https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062 35 | dotnet_diagnostic.CA1062.severity = none 36 | 37 | # CA1707: Identifiers should not contain underscores 38 | # Justification: Test method names contain underscores 39 | # https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1707 40 | dotnet_diagnostic.CA1707.severity = none 41 | 42 | dotnet_diagnostic.CS1591.severity = none 43 | 44 | # VSTHRD101: Avoid unsupported async delegates 45 | dotnet_diagnostic.VSTHRD101.severity = silent 46 | 47 | 48 | # VSTHRD101: Avoid unsupported async delegates 49 | dotnet_diagnostic.VSTHRD101.severity = suggestion 50 | -------------------------------------------------------------------------------- /Tests/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | runtime; build; native; contentfiles; analyzers; buildtransitive 8 | 9 | 10 | 11 | 12 | 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/HiveMQClient/ClientOptionsTest.cs: -------------------------------------------------------------------------------- 1 | namespace HiveMQtt.Test.HiveMQClient; 2 | 3 | using HiveMQtt.Client; 4 | using Xunit; 5 | 6 | public class ClientOptionsTest 7 | { 8 | [Fact] 9 | public void Client_ID() 10 | { 11 | var client = new HiveMQClient(); 12 | 13 | Assert.NotNull(client.Options.ClientId); 14 | Assert.True(client.Options.ClientId.Length < 24); 15 | Assert.Equal("127.0.0.1", client.Options.Host); 16 | Assert.Equal(1883, client.Options.Port); 17 | Assert.Equal(60, client.Options.KeepAlive); 18 | Assert.True(client.Options.CleanStart); 19 | Assert.Null(client.Options.UserName); 20 | Assert.Null(client.Options.Password); 21 | 22 | Assert.NotNull(client); 23 | 24 | client.Dispose(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/HiveMQClient/Plan/KeepAliveTest.cs: -------------------------------------------------------------------------------- 1 | namespace HiveMQtt.Test.HiveMQClient.Plan; 2 | 3 | using FluentAssertions; 4 | using HiveMQtt.Client; 5 | using NUnit.Framework; 6 | using System.Threading.Tasks; 7 | 8 | [TestFixture] 9 | public class KeepAliveTest 10 | { 11 | [Test] 12 | public async Task Client_Uses_Zero_As_Keep_Alive_No_Pings_Are_Sent_Async() 13 | { 14 | var options = new HiveMQClientOptionsBuilder() 15 | .WithKeepAlive(0) 16 | .Build(); 17 | var client = new HiveMQClient(options); 18 | 19 | client.Should().NotBeNull(); 20 | 21 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 22 | connectResult.Should().NotBeNull(); 23 | 24 | // Simulate waiting for a period longer than the keep-alive interval 25 | await Task.Delay(5000).ConfigureAwait(false); 26 | 27 | // Validate that no pings were sent 28 | // This would typically involve checking internal client state or logs 29 | // For this example, we'll assume a method IsPingSent exists 30 | client.IsPingSent().Should().BeFalse(); 31 | 32 | var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false); 33 | disconnectResult.Should().BeTrue(); 34 | } 35 | 36 | [Test] 37 | public async Task Client_Sends_Pings_After_Interval_Passed_Async() 38 | { 39 | var options = new HiveMQClientOptionsBuilder() 40 | .WithKeepAlive(5) // 5 seconds 41 | .Build(); 42 | var client = new HiveMQClient(options); 43 | 44 | client.Should().NotBeNull(); 45 | 46 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 47 | connectResult.Should().NotBeNull(); 48 | 49 | // Simulate waiting for a period longer than the keep-alive interval 50 | await Task.Delay(6000).ConfigureAwait(false); 51 | 52 | // Validate that pings were sent 53 | // This would typically involve checking internal client state or logs 54 | // For this example, we'll assume a method IsPingSent exists 55 | client.IsPingSent().Should().BeTrue(); 56 | 57 | var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false); 58 | disconnectResult.Should().BeTrue(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/HiveMQClient/Plan/PacketIDManagerTest.cs: -------------------------------------------------------------------------------- 1 | namespace HiveMQtt.Test.HiveMQClient.Plan; 2 | 3 | using HiveMQtt.Client; 4 | using HiveMQtt.MQTT5.Types; 5 | using Xunit; 6 | using System.Threading.Tasks; 7 | 8 | public class PacketIDManagerTest 9 | { 10 | [Fact] 11 | public async Task Send_1Mio_QoS1_QoS2_Messages_All_Ids_Released_Async() 12 | { 13 | // Arrange 14 | var clientOptions = new HiveMQClientOptionsBuilder() 15 | .WithClientId("PacketIDManagerTestClient") 16 | .WithBroker("localhost") 17 | .WithPort(1883) 18 | .Build(); 19 | 20 | var client = new HiveMQClient(clientOptions); 21 | await client.ConnectAsync().ConfigureAwait(true); 22 | 23 | var packetIdManager = client.Connection.GetPacketIDManager(); // Assuming the client exposes the manager for validation 24 | Assert.Equal(0, packetIdManager.Count); 25 | 26 | // Manually tested with 1M messages, 500k QoS1 and 500k QoS2 27 | // Lower the count for the test suite to remain manageable 28 | var qos1Messages = 5000; 29 | var qos2Messages = 5000; 30 | var totalMessages = qos1Messages + qos2Messages; 31 | 32 | // Act 33 | for (var i = 0; i < qos1Messages; i++) 34 | { 35 | await client.PublishAsync( 36 | topic: "test/qos1", 37 | payload: new byte[] { 0x01 }, 38 | qos: QualityOfService.AtLeastOnceDelivery).ConfigureAwait(true); 39 | } 40 | 41 | for (var i = 0; i < qos2Messages; i++) 42 | { 43 | await client.PublishAsync( 44 | topic: "test/qos2", 45 | payload: new byte[] { 0x02 }, 46 | qos: QualityOfService.ExactlyOnceDelivery).ConfigureAwait(true); 47 | } 48 | 49 | await client.DisconnectAsync().ConfigureAwait(true); 50 | 51 | // Assert 52 | Assert.Equal(0, packetIdManager.Count); // All Packet IDs must be released 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/HiveMQClient/TLSTest.cs: -------------------------------------------------------------------------------- 1 | namespace HiveMQtt.Test.HiveMQClient; 2 | 3 | using System.Threading.Tasks; 4 | using HiveMQtt.Client; 5 | using HiveMQtt.Client.Options; 6 | using HiveMQtt.MQTT5.ReasonCodes; 7 | using Xunit; 8 | 9 | public class TLSTest 10 | { 11 | #pragma warning disable xUnit1004 12 | [Fact(Skip = "Github CI failing: Need to be run manually")] 13 | #pragma warning restore xUnit1004 14 | public async Task Public_Broker_TLS_Async() 15 | { 16 | var options = new HiveMQClientOptions 17 | { 18 | Host = "broker.hivemq.com", 19 | Port = 8883, 20 | }; 21 | 22 | var client = new HiveMQClient(options); 23 | var connectResult = await client.ConnectAsync().ConfigureAwait(false); 24 | Assert.Equal(ConnAckReasonCode.Success, connectResult.ReasonCode); 25 | var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false); 26 | Assert.True(disconnectResult); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/HiveMQClient/TestFiles/hivemq-server-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDazCCAlOgAwIBAgIEFrmqYzANBgkqhkiG9w0BAQsFADBmMQswCQYDVQQGEwJJ 3 | VDELMAkGA1UECBMCUEExEDAOBgNVBAcTB1BhbGVybW8xDzANBgNVBAoTBkhpdmVN 4 | UTEXMBUGA1UECxMOSGl2ZU1RIENsaWVudHMxDjAMBgNVBAMTBVBldGVyMB4XDTI0 5 | MDEwMjExMTkwMloXDTI0MTIyNzExMTkwMlowZjELMAkGA1UEBhMCSVQxCzAJBgNV 6 | BAgTAlBBMRAwDgYDVQQHEwdQYWxlcm1vMQ8wDQYDVQQKEwZIaXZlTVExFzAVBgNV 7 | BAsTDkhpdmVNUSBDbGllbnRzMQ4wDAYDVQQDEwVQZXRlcjCCASIwDQYJKoZIhvcN 8 | AQEBBQADggEPADCCAQoCggEBAJCLG9ORnoZi+khkE//RqBPGYKqt2oJybHa+rxMR 9 | w2krhXrm5GmulTeEMQBMLj5iPkPHdebC/6jtFp0Z6jX+jGyVo2hvtP3NkXi04xUT 10 | jTnYTL7w9+0VEqAs+VldD/foi8JHDIouhHiPqMtZjIQBTNOCMbJA3ijc3V7v1k/S 11 | cVn9tny7R4vTNegdsVpmTg3dDl05IXSmM4RvHAFaTnfKhxDLovJZMFmw7W6UdAtw 12 | zaPaN6LyVbYv7S8AgCsQRFOc2jowep5noPuyKXwuep9zNZ5gY296UkhCubSHfM8o 13 | BTTiBV0Adjv9EiIy/LmZq9J1IW9l0JYxQCw4DzirzVdtqAMCAwEAAaMhMB8wHQYD 14 | VR0OBBYEFP5mNw74q4svHqU9jS8xzSgQkctNMA0GCSqGSIb3DQEBCwUAA4IBAQAr 15 | g+yIt3WVzib/XOHM+D0HWyb0OBmP8ZaTkIr3MhgaStq26xon0udyr9gImIuFNVOR 16 | h2tdQuI39ZMSTzHcRexCpJq/iuVjcjlSTfhGXrACmElywcEgRsUz0iETNcNOLtkT 17 | 7X6VJOCEraYK+iuXx48KZGisFpPz/rz8aQExiS8gxycARgT7N7IYba4fP9c87JjZ 18 | 5hr3hmBUMUmVH2KmDjVQDlKIZXEQrGmwOEUbpII0jlleLUuixGZykTnUEjwQ+htT 19 | tHDITkA1fR705wH2oMaz0eI6lukwNoNigX8j6H+O+O+3CgwUTOrtNxXZk+6y0fN6 20 | IafTOzh5YhNP9Ve1WHjd 21 | -----END CERTIFICATE----- 22 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/HiveMQtt.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | net6.0 6 | 7 | 8 | 9 | $(TargetFrameworks);net7.0 10 | 11 | 12 | 13 | 14 | $(TargetFrameworks);net8.0 15 | 16 | 17 | 18 | 19 | $(TargetFrameworks);net9.0 20 | 21 | 22 | 0.1.0 23 | true 24 | 25 | 26 | 27 | DEBUG;NET;NET8_0;NETCOREAPP 28 | 4 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | PreserveNewest 44 | 45 | 46 | PreserveNewest 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/Packets/ConnectPacketTest.cs: -------------------------------------------------------------------------------- 1 | namespace HiveMQtt.Test.Packets; 2 | 3 | using HiveMQtt.Client.Options; 4 | using HiveMQtt.MQTT5.Packets; 5 | using Xunit; 6 | 7 | public class ConnectPacketTest 8 | { 9 | [Fact] 10 | public void Encoding() 11 | { 12 | var options = new HiveMQClientOptions(); 13 | Assert.NotNull(options); 14 | 15 | var packet = new ConnectPacket(options); 16 | var packetData = packet.Encode(); 17 | Assert.NotNull(packetData); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | [assembly: CLSCompliant(true)] 2 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/Queues/AwaitableQueueXTest.cs: -------------------------------------------------------------------------------- 1 | namespace HiveMQtt.Test.Packets; 2 | 3 | using HiveMQtt.Client.Options; 4 | using HiveMQtt.Client.Internal; 5 | using HiveMQtt.MQTT5.Packets; 6 | using HiveMQtt.MQTT5; 7 | using Xunit; 8 | 9 | public class AwaitableQueueXTest 10 | { 11 | [Fact] 12 | public async Task WaitWhenEmptyAsync() 13 | { 14 | var queue = new AwaitableQueueX(); 15 | Assert.True(queue.IsEmpty); 16 | 17 | var options = new HiveMQClientOptions(); 18 | Assert.NotNull(options); 19 | 20 | var packet = new ConnectPacket(options); 21 | queue.Enqueue(packet); 22 | Assert.Equal(1, queue.Count); 23 | 24 | var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); 25 | 26 | ControlPacket? firstResult = null; 27 | ControlPacket? secondResult = null; 28 | var operationCanceled = false; 29 | try 30 | { 31 | // Get the first packet 32 | firstResult = await queue.DequeueAsync(cts.Token).ConfigureAwait(false); 33 | Assert.NotNull(firstResult); 34 | Assert.Equal(packet, firstResult); 35 | 36 | // The second dequeue call should wait until the cancellation token is timeout canceled 37 | secondResult = await queue.DequeueAsync(cts.Token).ConfigureAwait(false); 38 | } 39 | catch (OperationCanceledException) 40 | { 41 | operationCanceled = true; 42 | Assert.NotNull(firstResult); 43 | Assert.Null(secondResult); 44 | } 45 | 46 | Assert.True(operationCanceled); 47 | } 48 | 49 | [Fact] 50 | public void CanBeCleared() 51 | { 52 | var queue = new AwaitableQueueX(); 53 | Assert.True(queue.IsEmpty); 54 | 55 | var options = new HiveMQClientOptions(); 56 | Assert.NotNull(options); 57 | 58 | var packetOne = new ConnectPacket(options); 59 | queue.Enqueue(packetOne); 60 | Assert.Equal(1, queue.Count); 61 | 62 | var packetTwo = new ConnectPacket(options); 63 | queue.Enqueue(packetTwo); 64 | Assert.Equal(2, queue.Count); 65 | 66 | var packetThree = new ConnectPacket(options); 67 | queue.Enqueue(packetThree); 68 | Assert.Equal(3, queue.Count); 69 | 70 | queue.Clear(); 71 | Assert.True(queue.IsEmpty); 72 | Assert.Equal(0, queue.Count); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Tests/HiveMQtt.Test/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "parallelizeAssembly": false, 3 | "parallelizeTestCollections": false, 4 | "execution": { 5 | "maxParallelThreads": 1, 6 | "maxParallelAssemblies": 1, 7 | "maxParallelTestCollections": 1, 8 | "parallelizeTestCollections": false, 9 | "disableParallelization": true, 10 | "stopOnFail": false 11 | }, 12 | "timing": { 13 | "before": 1000 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "cake.tool": { 6 | "version": "4.2.0", 7 | "commands": [ 8 | "dotnet-cake" 9 | ], 10 | "rollForward": false 11 | }, 12 | "docfx": { 13 | "version": "2.74.1", 14 | "commands": [ 15 | "docfx" 16 | ], 17 | "rollForward": false 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /stylecop.json: -------------------------------------------------------------------------------- 1 | { 2 | "settings": { 3 | "documentationRules": { 4 | "companyName": "HiveMQ", 5 | "copyrightText": "Copyright 2022-present HiveMQ and the HiveMQ Community" 6 | } 7 | } 8 | } 9 | --------------------------------------------------------------------------------