Created
April 10, 2024 21:06
-
-
Save jainal09/d0ed26670286233e672cf2f42a2439ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def connect(self, websocket: WebSocket, client_id: str) -> None: | |
""" | |
Connect the WebSocket | |
Args: | |
websocket: WebSocket | |
id: Client ID | |
Returns: | |
None | |
""" | |
print(f"Read Flag: {read_flag()}") | |
if read_flag(): # Check if the flag is True for the server to accept connections | |
await websocket.accept() | |
await websocket.send_text(get_pod_name()) | |
self.active_connections[client_id] = websocket | |
else: | |
await websocket.close(code=1000) # Close the connection without accepting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment