Skip to content

RFE - add protocols option to WS constructor #365

@space88man

Description

@space88man

Is your feature request related to a problem? Please describe.
WebSocketTransport.ts does not accept a protocols option to the constructor of WS

Describe the solution you'd like

constructor(uri: string, protocols?: string | string[]) {
    super();
    this.uri = uri;
    this.connection = new WS(uri, protocols);
  }

Describe alternatives you've considered

  • subclass Transport - but this class is not exposed in v2.0.0 (in v1.8.1 - this could be hacked by import from @open-rpc/client-js/build/transports/Transport
  • subclass WebSocketTransport - this works but there will be a bogus WS connection due to WS(url, protocols === undefined) in super(); in the subclass the second call to WS(url, protocols) will succeed

Additional context
In v2.0.0 the workaround is to hack using node_modules/@open-rpc/client-js/dist/transports/Transport

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions