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

feat(peer): add close and terminate #36

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

posva
Copy link

@posva posva commented Apr 22, 2024

πŸ”— Linked issue

Close #23

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@posva
Copy link
Author

posva commented Apr 22, 2024

I'm unsure if this is the desired direction, and I haven't tested the different implementations, only Node. Feel free to push any changes you wish

@@ -108,4 +108,15 @@ class CloudflarePeer extends Peer<{
this.ctx.cloudflare.server.send(toBufferLike(message));
return 0;
}

close(code?: number, reason?: string) {
this.ctx.cloudflare.client.close(code, reason);
Copy link
Author

Choose a reason for hiding this comment

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

I'm not familiar with Cloudflare websockets and having two of them so this could be wrong

* @param code The close code to send
* @param reason The close reason to send
*/
abstract close(code?: number, reason?: string): void;
Copy link
Member

@pi0 pi0 Apr 22, 2024

Choose a reason for hiding this comment

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

What do you think to support it as { code?: number, reason?: string, terminate?: boolean } to keep simility? (also many providers might not respect terminate and behave it same as close)

Copy link
Author

Choose a reason for hiding this comment

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

It's up to you. Given that termination seems to send a specific code, having a direct helper seems to be more appropriate. Most providers seem to have it. When searching online for the feature I found both close() and terminate(), so I would say it's more intuitive to have two distinct methods than one with an extra argument at the very end

Copy link
Member

Choose a reason for hiding this comment

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

okay, thanks for context. let me research little more when could to decide.

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.

Add a method to close the connection for Peer
2 participants