Skip to content

Commit

Permalink
Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
syn committed Sep 12, 2016
1 parent 5fe8db9 commit 9ebfa46
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,4 @@
recursive-include instant/static *
recursive-include instant/migrations *
recursive-include instant/templates *
recursive-include instant/templatetags *
30 changes: 30 additions & 0 deletions instant/producers.py
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-

from string import lower
from cent.core import Client
from instant.utils import format_event_class
from instant.conf import SITE_NAME, CENTRIFUGO_HOST, CENTRIFUGO_PORT, SECRET_KEY, SITE_SLUG


def broadcast(message, event_class="default", data={}, channel=None, site=SITE_NAME, message_label=None, target=None):
cent_url = CENTRIFUGO_HOST+":"+str(CENTRIFUGO_PORT)
client = Client(cent_url, SECRET_KEY, timeout=1)
if channel is None:
if target is not None:
if target == "superuser":
channel = "$"+SITE_SLUG+'_admin'
if target == "staff":
channel = "$"+SITE_SLUG+'_staff'
if target == "users":
channel = "$"+SITE_SLUG+'_users'
else:
return False, None
else:
_get_public_channel()
if message_label is None:
message_label = format_event_class(obj=None, event_class=event_class)
payload = {"message": message, "channel":channel, 'message_label':message_label, 'event_class':event_class, "data":data , "site":site}
client.publish(channel, payload)
if lower(event_class) == "debug":
print "[DEBUG] "+str(json.dumps(payload))
return True, channel
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
28 changes: 28 additions & 0 deletions setup.py
@@ -0,0 +1,28 @@
from setuptools import setup, find_packages


version = __import__('instant').__version__

setup(
name = 'django-instant',
packages=find_packages(),
include_package_data=True,
version = version,
description = 'Websockets for Django with Centrifugo ',
author = 'synw',
author_email = 'synwe@yahoo.com',
url = 'https://github.com/synw/django-instant',
download_url = 'https://github.com/synw/django-instant/releases/tag/'+version,
keywords = ['django', 'websockets', 'centrifugo'],
classifiers = [
'Development Status :: 3 - Alpha',
'Framework :: Django :: 1.9',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2.7',
],
install_requires=[
'cent',
],
zip_safe=False
)

0 comments on commit 9ebfa46

Please sign in to comment.