stash
This commit is contained in:
parent
06112340dc
commit
82c11feecf
1 changed files with 4 additions and 1 deletions
|
@ -3,6 +3,7 @@ from channels.layers import get_channel_layer
|
||||||
|
|
||||||
class NotificationDispatcher:
|
class NotificationDispatcher:
|
||||||
channel_layer = None
|
channel_layer = None
|
||||||
|
channel_name = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.channel_layer = get_channel_layer()
|
self.channel_layer = get_channel_layer()
|
||||||
|
@ -12,9 +13,11 @@ class NotificationDispatcher:
|
||||||
async def run_forever(self):
|
async def run_forever(self):
|
||||||
# Infinite loop to continuously listen for messages
|
# Infinite loop to continuously listen for messages
|
||||||
print("Listening for messages...")
|
print("Listening for messages...")
|
||||||
|
self.channel_name = await self.channel_layer.new_channel()
|
||||||
|
print("Channel name:", self.channel_name)
|
||||||
while True:
|
while True:
|
||||||
# Blocking receive to get the message from the channel layer
|
# Blocking receive to get the message from the channel layer
|
||||||
message = await self.channel_layer.receive('general')
|
message = await self.channel_layer.receive(self.channel_name)
|
||||||
|
|
||||||
if message:
|
if message:
|
||||||
# Process the received message
|
# Process the received message
|
||||||
|
|
Loading…
Reference in a new issue