ajndkr / lanarky

The web framework for building LLM microservices
https://lanarky.ajndkr.com/
MIT License
975 stars 74 forks source link

feat: Add option to accept or not accept WebSocket connection #89

Closed Tooflex closed 1 year ago

Tooflex commented 1 year ago

Description

This pull request introduces a new feature that allows the connect() method in the WebsocketConnection class to control whether to accept the WebSocket connection or not.

This is done by adding a new parameter accept_connection to the connect()method. By default, this parameter is set to True, meaning the WebSocket connection will be accepted when the connect() method is called.

However, if accept_connection is set to False, the connect() method will not attempt to accept the WebSocket connection.

This feature is particularly useful in scenarios where the first message from the client after establishing the WebSocket connection is used for authentication purposes.

Fixes #86

Changelog:

Added a new parameter accept_connection to the connect() method in the WebsocketConnection class. Added a new connection_accepted variable to track if connection was already accepted Added new tests to verify the functionality of the accept_connection parameter.