-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
387 additions
and
220 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ output/*/index.html | |
# Sphinx | ||
docs/_build | ||
.eggs | ||
local.sqlite |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ Contributors | |
|
||
* Adam Chainz | ||
* Daniel Rios | ||
* Daniel Santos |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
from channels import Group | ||
from channels.sessions import channel_session | ||
from channels.generic.websocket import JsonWebsocketConsumer | ||
|
||
|
||
@channel_session | ||
def ws_connect(message): | ||
""" | ||
Channels connection setup. | ||
Register the current client on the related Group according to the language | ||
""" | ||
prefix, language = message['path'].strip('/').split('/') | ||
gr = Group('knocker-{0}'.format(language)) | ||
gr.add(message.reply_channel) | ||
message.channel_session['knocker'] = language | ||
message.reply_channel.send({"accept": True}) | ||
class KnockerConsumer(JsonWebsocketConsumer): | ||
|
||
@property | ||
def groups(self): | ||
""" | ||
Attach the consumer to the selected language | ||
""" | ||
lang = self.scope['url_route']['kwargs'].get('language') | ||
return 'knocker-%s' % lang, | ||
|
||
@channel_session | ||
def ws_receive(message): | ||
""" | ||
Currently no-op | ||
""" | ||
pass | ||
def knocker_saved(self, event): | ||
""" | ||
This method handles messages sent to knocker.saved | ||
|
||
@channel_session | ||
def ws_disconnect(message): | ||
""" | ||
Channels connection close. | ||
Deregister the client | ||
""" | ||
language = message.channel_session['knocker'] | ||
gr = Group('knocker-{0}'.format(language)) | ||
gr.discard(message.reply_channel) | ||
:param event: event object | ||
""" | ||
self.send_json(content=event['message']) |
Oops, something went wrong.