I have just started to use Django channels with djangochannelrestframework
and playing around with it. Right now I am trying to let the server side send me back messages to my browser (Not to group). Here is my code:
consumer.py
class SimulationConsumer(ObserverModelInstanceMixin, GenericAsyncAPIConsumer):
async def connect(self):
await self.accept()
print("Connected to simulation core. ")
@action()
async def test(self, **kwargs):
message = ("Success")
print(message)
await self.send(message)
When I tested the code with browser with the following script, I don’t see any responses back.
Which I am expecting to see “Success” from the second command but it becomes undefined. Just wanted to know what I am missing (and where in the documentations that can shed me a light)?
Update: Don’t worry about the endpoint URL, I copied the tutorial just to try out. At the serverside I can see "Connected to simulation core. " and “Success” printed but not the on my browser.