Skip to content

Commit

Permalink
Merge pull request #48 from kaandesu/fix/create_client
Browse files Browse the repository at this point in the history
fix: createClient
  • Loading branch information
kaandesu authored Apr 15, 2023
2 parents 7556bf4 + 4c9a20a commit 20e7bfc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-apes-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vue-paho-mqtt': patch
---

fixed an issue that disabled changing the default mqtt options
22 changes: 11 additions & 11 deletions src/pahoMqttPlugin/config/client.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { Client } from 'paho-mqtt';
import { getMqttOptions } from './options';
import { getMqttOptions, setMqttOptions } from './options';
import { MqttOptions } from '../types';
const MqttOptions = getMqttOptions();
const mqttOptions = getMqttOptions();

let client = new Client(
MqttOptions.host,
MqttOptions.port,
MqttOptions.clientId,
mqttOptions.host,
mqttOptions.port,
mqttOptions.clientId,
);

export const getClient = () => client;
export const createClient = (
options: MqttOptions = {
host: MqttOptions.host,
port: MqttOptions.port,
clientId: MqttOptions.clientId,
host: getMqttOptions().host,
port: getMqttOptions().port,
clientId: getMqttOptions().clientId,
},
) => {
client = new Client(
(MqttOptions.host = options.host),
(MqttOptions.port = options.port),
(MqttOptions.clientId = options.clientId),
(mqttOptions.host = options.host),
(mqttOptions.port = options.port),
(mqttOptions.clientId = options.clientId),
);
return client;
};

0 comments on commit 20e7bfc

Please sign in to comment.