diff --git a/awx/main/consumers.py b/awx/main/consumers.py new file mode 100644 index 0000000000..de196eb866 --- /dev/null +++ b/awx/main/consumers.py @@ -0,0 +1,13 @@ +from channels import Group +from channels.sessions import channel_session + + +@channel_session +def job_event_connect(message): + job_id = message.content['path'].strip('/') + message.channel_session['job_id'] = job_id + Group("job_events-%s" % job_id).add(message.reply_channel) + +def emit_channel_notification(event, payload): + Group(event).send(payload) + diff --git a/awx/main/routing.py b/awx/main/routing.py new file mode 100644 index 0000000000..6156a295a9 --- /dev/null +++ b/awx/main/routing.py @@ -0,0 +1,6 @@ +from channels.routing import route + + +channel_routing = [ + route("websocket.connect", "awx.main.consumers.job_event_connect", path=r'^/job_event/(?P[a-zA-Z0-9_]+)/$'), +]