Pithikos / python-websocket-server

A simple fully working websocket-server in Python with no external dependencies
MIT License
1.14k stars 384 forks source link

Single client disconnection #107

Open Tyris0001 opened 1 year ago

Tyris0001 commented 1 year ago

I do have reason to believe that this works.

Pithikos commented 1 year ago

Thanks for this. However some refactoring will be required before I'll be able to merge this.

Namely there's two main issues:

  1. There's some discussion of having a dictionary of clients (https://github.com/Pithikos/python-websocket-server/issues/66). That will avoid unnecessary loops.
  2. I try to avoid introducing new functions if it can be done with existing ones. I think a better implementation would be to change the existing methods to simply take clients as either a list of client_id or client. That will cover more arbitrary cases (e.g. closing 2 or 3 clients) without changing the API that much. So by default all clients are disconnected unless user specifies specific clients.
jason-c-child commented 1 year ago

Thanks for this. However some refactoring will be required before I'll be able to merge this.

The inability to disconnect a specific client by id is a massive miss here and seriously hobbles the utility of this library.