Skip to content

Instantly share code, notes, and snippets.

@jainal09
Created April 10, 2024 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jainal09/d0ed26670286233e672cf2f42a2439ea to your computer and use it in GitHub Desktop.
Save jainal09/d0ed26670286233e672cf2f42a2439ea to your computer and use it in GitHub Desktop.
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