Git Product home page Git Product logo

Comments (4)

miguelgrinberg avatar miguelgrinberg commented on May 23, 2024

This works fine for me using the same releases you listed above. Are you using the example app? With it I can broadcast using the second text field, and all the clients get the server generated events every few seconds, so all seems to be working fine.

from flask-socketio.

iurisilvio avatar iurisilvio commented on May 23, 2024

It is not the example, but I reproduced it with the example, removing namespaces. I'm runing without namespaces, maybe this is the problem.

Here, my diff to reproduce the problem.

diff --git a/example/app.py b/example/app.py
index 33a1d90..015400d 100644
--- a/example/app.py
+++ b/example/app.py
@@ -20,8 +20,7 @@ def background_thread():
         time.sleep(10)
         count += 1
         socketio.emit('my response',
-                      {'data': 'Server generated event', 'count': count},
-                      namespace='/test')
+                      {'data': 'Server generated event', 'count': count})


 @app.route('/')
@@ -33,14 +32,14 @@ def index():
     return render_template('index.html')


[email protected]('my event', namespace='/test')
[email protected]('my event')
 def test_message(message):
     session['receive_count'] = session.get('receive_count', 0) + 1
     emit('my response',
          {'data': message['data'], 'count': session['receive_count']})


[email protected]('my broadcast event', namespace='/test')
[email protected]('my broadcast event')
 def test_message(message):
     session['receive_count'] = session.get('receive_count', 0) + 1
     emit('my response',
@@ -48,7 +47,7 @@ def test_message(message):
          broadcast=True)


[email protected]('join', namespace='/test')
[email protected]('join')
 def join(message):
     join_room(message['room'])
     session['receive_count'] = session.get('receive_count', 0) + 1
@@ -57,7 +56,7 @@ def join(message):
           'count': session['receive_count']})


[email protected]('leave', namespace='/test')
[email protected]('leave')
 def leave(message):
     leave_room(message['room'])
     session['receive_count'] = session.get('receive_count', 0) + 1
@@ -66,7 +65,7 @@ def leave(message):
           'count': session['receive_count']})


[email protected]('my room event', namespace='/test')
[email protected]('my room event')
 def send_room_message(message):
     session['receive_count'] = session.get('receive_count', 0) + 1
     emit('my response',
@@ -74,12 +73,12 @@ def send_room_message(message):
          room=message['room'])


[email protected]('connect', namespace='/test')
[email protected]('connect')
 def test_connect():
     emit('my response', {'data': 'Connected', 'count': 0})


[email protected]('disconnect', namespace='/test')
[email protected]('disconnect')
 def test_disconnect():
     print('Client disconnected')

diff --git a/example/templates/index.html b/example/templates/index.html
index 3896634..2f4b8a2 100644
--- a/example/templates/index.html
+++ b/example/templates/index.html
@@ -6,7 +6,7 @@
     <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script>
     <script type="text/javascript" charset="utf-8">
         $(document).ready(function(){
-            namespace = '/test'; // change to an empty string to use the global namespace
+            namespace = '/'; // change to an empty string to use the global namespace

             // the socket.io documentation recommends sending an explicit package upon connection
             // this is specially important when using the global namespace

from flask-socketio.

miguelgrinberg avatar miguelgrinberg commented on May 23, 2024

This is addressed in version 0.3.8, just pushed to pypi.

from flask-socketio.

iurisilvio avatar iurisilvio commented on May 23, 2024

Thanks! It worked for me.

from flask-socketio.

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.