I got a heroku server running on one web processing, in the routing.py I have
application = ProtocolTypeRouter({
'websocket': backEndConsumer,
'http': frontEndConsumer,
})
my frontEndConsumer handles the http webhook requests and my backEndConsumer handles all my websocket requests.
When a device with the correct address tries to talk to my websocket, it will go to backEndConsumer and run the websocket_connect()
Then on my frontEndconsumer, It will get a http_request().
I want this http_request() to trigger the backEndConsumer to do a websocket_send(). I can't seem to get that to work.
webhook.py
scope = None
import myapp.consumers
class frontEndConsumer(AsyncHttpConsumer):
async def http_request(self, request):
myapp.consumers.backEndConsumer.frontSend(myapp.consumers.scope)
await self.send_response(200, b"finished",
headers=[(b"Content-Type", b"text/plain"),])
consumers.py
class backEndConsumer(AsyncJsonWebsocketConsumer):
async def websocket_connect(self, type):
await self.accept()
global scope
scope = self # doing this to pass the object to frontEndConsumer
async def frontSend(self):
await self.send("Hello world!")
I keep getting this error
myapp.consumers.backEndConsumer.frontSend()
frontSend() missing 1 required positional argument: 'self'
I know I am doing something wrong, but I am not sure how to do what I want.