Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@channel_session_user_from_http
def ws_connect(message):
if (message.content['path'] == '/'):
Group("ws_logger").add(message.reply_channel)
return
prefix, user, session = message.content['path'].strip('/').split('/')
prefix = str(prefix)
if (prefix != "ws_logger"):
return
user = str(user)
session = str(session)
message.channel_session['user'] = user
message.channel_session['session_key'] = session
@channel_session_user_from_http
def ws_connect(message):
message.reply_channel.send({'accept': True})
message.channel_session['room'] = []
@channel_session_user_from_http
def loadhistory_connect(message):
message.reply_channel.send({"accept": True})
@channel_session_user_from_http
def ws_connect(message):
# Initialise their session
# like django session
message.channel_session['rooms'] = []
@channel_session_user_from_http
def ws_connect(message):
path = message.content['path']
room_label = path.replace('/chat/inbox/', '').replace('/', '')
room = Room.objects.get(label=room_label)
Group('chat-' + room_label).add(message.reply_channel)
message.channel_session['room'] = room.label
@channel_session_user_from_http
def websocket_connect_onduty(message):
if not message.user.is_authenticated():
logger.error('websocket_connect_onduty. user = %s is NOT authenticated', message.user)
return
logger.debug('websocket_connect_events. user = %s', message.user)
Group("on-duty").add(message.reply_channel)
Group("announcement").add(message.reply_channel)
message.reply_channel.send({"accept": True})
@channel_session_user_from_http
def ws_connect(message):
if not message.user.is_authenticated():
logger.error("Request user is not authenticated to use websocket.")
message.reply_channel.send({"close": True})
return
else:
message.reply_channel.send({"accept": True})
data = urlparse.parse_qs(message.content['query_string'])
inventory_id = parse_inventory_id(data)
try:
inventory = Inventory.objects.get(id=inventory_id)
except Inventory.DoesNotExist:
logger.error("User {} attempted connecting inventory_id {} that does not exist.".format(
message.user.id, inventory_id)
)
@channel_session_user_from_http
def mark_present(message):
ip, port = message['client']
wlogger.info('msg ip: %s, port: %s' % (ip, port))
a = Attendant(ip=ip, port=port, channel_name=message.reply_channel.name,
user=message.user.username,
details=get_request_params(message['query_string']))
store.hset(ONLINE, message.reply_channel.name, a.dumps())
message.reply_channel.send({'accept': True})
@channel_session_user_from_http
def ws_add(message):
# Accept connection
message.reply_channel.send({"accept": True})
# Add them to the user group
Group('%s' % message.user.id).add(message.reply_channel)
@channel_session_user_from_http
def ws_connect(message):
print('Connection being established...')
message.reply_channel.send({
'accept': True
})
# extracting id of network from url params
params = urlparse.parse_qs(message.content['query_string'])
networkId = params.get('id', ('Not Supplied',))[0]
message.channel_session['networkId'] = networkId
# adding socket to a group based on networkId to send updates of network
Group('model-{0}'.format(networkId)).add(message.reply_channel)