Giter Club home page Giter Club logo

Comments (6)

jrief avatar jrief commented on July 28, 2024

using which API?

BTW, which version

from django-websocket-redis.

jrief avatar jrief commented on July 28, 2024

Did you implement it as written here?
http://django-websocket-redis.readthedocs.org/en/latest/api.html

from django-websocket-redis.

luogni avatar luogni commented on July 28, 2024

i'm using current git and i need to publish messages to different facilities from a celery task so i do:
b = RedisPublisher(facility='team-0", broadcast=True)
b.publish_message("test0")
b = RedisPublisher(facility='team-1", broadcast=True)
b.publish_message("test1")
The first message will go to "team-0" but the second message will go to both team-0 and team-1.

from django-websocket-redis.

luogni avatar luogni commented on July 28, 2024

(current git as yesterday.. i didn't have time to check again today)

from django-websocket-redis.

jrief avatar jrief commented on July 28, 2024

If you want to dispatch a message to different users, instead of using a different facility, you should use a different audience, say:

b = RedisPublisher(facility='a_name', user='team-0')
b.publish_message("test0")
b = RedisPublisher(facility='a_name', user='team-1')
b.publish_message("test1")

but anyway, your code is correct and indeed this seems weird.
Could you please check with redis-cli what kind of messages have been added.
For this WS4REDIS_EXPIRE must be, say 3600.

# redis-cli
redis 127.0.0.1:6379> get broadcast:team-0
redis 127.0.0.1:6379> get broadcast:team-1

from django-websocket-redis.

luogni avatar luogni commented on July 28, 2024

As i said(maybe i've not explained it very well, sorry for that!) in the first report the problem is that the class RedisStore declares _publishers as a class variable. This means that all RedisStore instances will share the same _publishers variable. For example this code:

class TestC:
    _a = []
    def __init__(self):
        self._b = []

    def test(self):
        self._a.append('a')
        self._b.append('b')
        return (self._a, self._b)

b = TestC()
print b.test()
c = TestC()
print c.test()

will output

(['a'], ['b'])
(['a', 'a'], ['b'])

You don't want _publishers to be a class variable but an instance variable and so you have to declare it inside init. I hope i made myself clear!

from django-websocket-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.