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:
|
if not allow_connect:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
setattr(client, "broadcast_event", self.broadcast_event)
|
self._set_client_callbacks(client)
|
||||||
def get_client_config() -> ClientConfig:
|
|
||||||
return self.get_relay_config(client.relay_id)
|
|
||||||
setattr(client, "get_client_config", get_client_config)
|
|
||||||
|
|
||||||
self.clients(client.relay_id).append(client)
|
self.clients(client.relay_id).append(client)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def remove_client(self, c: "NostrClientConnection"):
|
def remove_client(self, c: "NostrClientConnection"):
|
||||||
self.clients(c.relay_id).remove(c)
|
self.clients(c.relay_id).remove(c)
|
||||||
|
|
||||||
|
|
@ -77,6 +75,12 @@ class NostrClientManager:
|
||||||
return False
|
return False
|
||||||
#todo: NIP-42: AUTH
|
#todo: NIP-42: AUTH
|
||||||
return True
|
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:
|
class NostrClientConnection:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue