-
-
Notifications
You must be signed in to change notification settings - Fork 793
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
1 parent
aa921b1
commit 8492dcd
Showing
7 changed files
with
278 additions
and
34 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import functools | ||
|
||
from django.utils import six | ||
|
||
from channels import channel_backends, DEFAULT_CHANNEL_BACKEND | ||
|
||
|
||
def consumer(self, *channels, alias=DEFAULT_CHANNEL_BACKEND): | ||
""" | ||
Decorator that registers a function as a consumer. | ||
""" | ||
# Upconvert if you just pass in a string | ||
if isinstance(channels, six.string_types): | ||
channels = [channels] | ||
# Get the channel | ||
channel_backend = channel_backends[alias] | ||
# Return a function that'll register whatever it wraps | ||
def inner(func): | ||
channel_backend.registry.add_consumer(func, channels) | ||
return func | ||
return inner | ||
|
||
|
||
# TODO: Sessions, auth |
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
Oops, something went wrong.