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 |
16 |
17 |
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 |
--------------------------------------------------------------------------------