Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT Client ID should be part of ClientOptions #40

Open
mechatheo opened this issue Sep 4, 2024 · 0 comments
Open

MQTT Client ID should be part of ClientOptions #40

mechatheo opened this issue Sep 4, 2024 · 0 comments

Comments

@mechatheo
Copy link

Hello,

I noticed the clientId is a readonly property of the Client interface. However, very often the client id is used as an active part of the communication, e.g. for security reasons a filter is implemented and a specific client id must be set in a given network.
There is a comment saying that the id is only used for logging, which is not the case, as can be seen here:

clientId: this.clientId,

So ideally I would suggest the client id should be part of ClientOptions.transport along with all other settings. At very least it should be made writable, to avoid hacks like those:

type Writable<T> = { -readonly [P in keyof T]: T[P] };
type WritableClient = Writable<Client>;

export class MyController extends AgvController {
    constructor(agvId: AgvId, clientOptions: ClientOptions, controllerOptions: AgvControllerOptions, adapterOptions: AgvAdapterOptions) {
        super(agvId, clientOptions, controllerOptions, adapterOptions);
        if ((adapterOptions as MyAdapterOptions).clientId !== undefined) {
            (this as WritableClient).clientId = (adapterOptions as MyAdapterOptions).clientId as string;
        }
    }
    ...
}

what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant