Skip to content

Conversation

@skoshx
Copy link

@skoshx skoshx commented Jul 24, 2022

This PR adds a protocol option to the PeerOptions, that users can use to for instance choose different versions of Peer servers, and more.

skoshx added 3 commits July 24, 2022 17:57
This commit adds support for defining which WebSocket protocol a Peer instance should use.

This makes it possible to for instance use versioning for Peer servers, and much more.
Copy link
Member

@jonasgloning jonasgloning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!
Out of curiosity, what protocol do you want to set for your application?

I'm hesitant about allowing user protocols without prefixes because PeerJS might want to set its own in the future.
We could also reserve the peerjs- prefix for us, but I don't know how to express this in typescript.

config?: any;
secure?: boolean;
pingInterval?: number;
protocol?: string | string[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this only accepts strings starting with a prefix.
What do you think about the type: x-${Lowercase<string>}?

That way PeerJS can still set its own protocols without interference from user-protocols.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then this would force the hands of users to either (1) use protcols named x-${Lowercase<string>}, which would not always be possible, since the user might be using a WebSocket server not controlled by then, and that WebSocket server might have a protocol name that doesn't confine to the above types...

path: string,
key: string,
private readonly pingInterval: number = 5000,
private readonly protocol: string | string[] | undefined = undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's skip undefined and initialize this to []

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

Successfully merging this pull request may close these issues.

2 participants