Checkpoint
This commit is contained in:
@@ -2,9 +2,9 @@ import mqtt from "mqtt";
|
||||
import type { StreamConnectionOptions, StreamState, TopicSubscription } from "../types/stream.types";
|
||||
|
||||
const defaultConnectionOptions: StreamConnectionOptions = {
|
||||
url: import.meta.env.DEV
|
||||
? 'ws://10.42.23.73:8083'
|
||||
: ((window.location.protocol === 'http:') ? 'ws:' : 'wss:') + '//' + window.location.host + '/broker'
|
||||
url: import.meta.env.DEV ?
|
||||
'wss://pd0mz.hamnet.nl/broker' :
|
||||
((window.location.protocol === 'http:') ? 'ws:' : 'wss:') + '//' + window.location.host + '/broker'
|
||||
}
|
||||
|
||||
export abstract class BaseStream {
|
||||
@@ -12,7 +12,7 @@ export abstract class BaseStream {
|
||||
protected connectionOptions: StreamConnectionOptions;
|
||||
protected subscribers: Map<string, Set<(data: any, topic: string) => void>> = new Map();
|
||||
protected stateSubscribers: Set<(state: StreamState) => void> = new Set();
|
||||
protected reconnectTimer: NodeJS.Timeout | null = null;
|
||||
protected reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
protected autoConnect: boolean;
|
||||
|
||||
protected state: StreamState = {
|
||||
@@ -48,7 +48,9 @@ export abstract class BaseStream {
|
||||
try {
|
||||
const randomId = Math.random().toString(16).slice(2, 10);
|
||||
const prefix = import.meta.env.DEV ? 'dev_' : '';
|
||||
const defaultClientId = `${prefix}hamview_${randomId}`;
|
||||
const defaultClientId = `${prefix}web_${randomId}`;
|
||||
|
||||
console.log(`Connecting to MQTT broker at ${this.connectionOptions.url} with clientId ${defaultClientId}`);
|
||||
|
||||
this.client = mqtt.connect(this.connectionOptions.url, {
|
||||
...this.connectionOptions.options,
|
||||
|
||||
Reference in New Issue
Block a user