Skip to content
Snippets Groups Projects
Commit 71225cd6 authored by ManosAngelidis's avatar ManosAngelidis
Browse files

[NRRPLT-8384-mqtt Added unsubscribe]

parent a17229af
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
{
"name": "nrp-frontend",
"jest": {
"coverageReporters": [
"html",
"cobertura"
],
"collectCoverageFrom": [
"src/services/**/*.js"
]
},
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "4.11.3",
"@material-ui/icons": "4.11.2",
"@material-ui/lab": "4.0.0-alpha.57",
"bootstrap": "4.5",
"flexlayout-react": "0.5.5",
"google-protobuf": "3.21.0",
"jquery": "3.6.0",
"jszip": "3.2.0",
"mqtt": "4.3.5",
"nrp-jsproto": "1.1.1-alpha.20",
"protobufjs": "6.11.2",
"react": "^17.0.1",
"react-bootstrap": "1.4.0",
"react-dom": "^17.0.1",
"react-icons": "4.1.0",
"react-router-dom": "5.2.0",
"react-scripts": "4.0.3",
"react-tabs": "3.1.2",
"roslib": "1.1.0",
"rxjs": "6.6.3",
"web-vitals": "^0.2.4"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@typescript-eslint/parser": "4.14.2",
"eslint": "7.19.0",
"jest-fetch-mock": "^3.0.3",
"jest-localstorage-mock": "2.4.6",
"msw": "^0.23.0",
"node": "16.1.0",
"ts-node": "^9.1.1",
"typescript": "4.1.3"
},
"scripts": {
"start": "react-scripts start",
"startHTTPS": "HTTPS=true react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"coverage": "npm run test -- --coverage --watchAll=false"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
......@@ -25,7 +25,9 @@ export default class NrpCoreDashboard extends React.Component {
let token2 = MqttClientService.instance.subscribeToTopic('test_topic', (param1) => (console.info(param1)));
let token3 = MqttClientService.instance.subscribeToTopic('test_topic', (param1) => (console.info(param1)));
let token4 = MqttClientService.instance.subscribeToTopic('test_topic_proto', (param1) => (console.info(param1)));
//TODO: test unsubscribe once implemented
// Test unsubscribe
MqttClientService.instance.unsubscribe(token3);
}
render() {
......
......@@ -100,6 +100,20 @@ export default class MqttClientService extends EventEmitter {
return token;
}
unsubscribe(unsubToken) {
if (this.subTokensMap.has(unsubToken.topic)){
this.subTokensMap.get(unsubToken.topic).forEach(token => {
if (token === unsubToken){
this.subTokensMap.get(unsubToken.topic).pop(token);
console.info('You have been unsubscribed from topic ' + unsubToken.topic);
};
});
}
else{
console.info('The topic ' + unsubToken.topic + ' was not found');
}
}
static getProtoOneofData(protoMsg, oneofCaseNumber) {
return jspb.Message.getField(protoMsg, oneofCaseNumber);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment