refactor: extract method _set_client_callbacks()
This commit is contained in:
parent
423364a5c6
commit
9501286c1f
1 changed files with 8 additions and 4 deletions
|
|
@ -29,15 +29,13 @@ class NostrClientManager:
|
|||
if not allow_connect:
|
||||
return False
|
||||
|
||||
setattr(client, "broadcast_event", self.broadcast_event)
|
||||
def get_client_config() -> ClientConfig:
|
||||
return self.get_relay_config(client.relay_id)
|
||||
setattr(client, "get_client_config", get_client_config)
|
||||
self._set_client_callbacks(client)
|
||||
|
||||
self.clients(client.relay_id).append(client)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def remove_client(self, c: "NostrClientConnection"):
|
||||
self.clients(c.relay_id).remove(c)
|
||||
|
||||
|
|
@ -78,6 +76,12 @@ class NostrClientManager:
|
|||
#todo: NIP-42: AUTH
|
||||
return True
|
||||
|
||||
def _set_client_callbacks(self, client):
|
||||
setattr(client, "broadcast_event", self.broadcast_event)
|
||||
def get_client_config() -> ClientConfig:
|
||||
return self.get_relay_config(client.relay_id)
|
||||
setattr(client, "get_client_config", get_client_config)
|
||||
|
||||
class NostrClientConnection:
|
||||
|
||||
def __init__(self, relay_id: str, websocket: WebSocket):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue