This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Django settings for sensor project. | |
Generated by 'django-admin startproject' using Django 1.9.2. | |
For more information on this file, see | |
https://docs.djangoproject.com/en/1.9/topics/settings/ | |
For the full list of settings and their values, see | |
https://docs.djangoproject.com/en/1.9/ref/settings/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from channels import Group | |
def ws_connect(message): | |
print("Someone connected.") | |
path = message['path'] # i.e. /sensor/ | |
if path == b’/sensor/': | |
print("Adding new user to sensor group") | |
Group(“sensor").add(message.reply_channel) # Adds user to group for broadcast | |
message.reply_channel.send({ # Reply to individual directly |
NewerOlder