From 883e73e548869ca6896e6b6cc6f44627c0168499 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Mon, 20 Jul 2015 00:21:49 -0700 Subject: [PATCH] Replaced gevent, gevent-socketio and gevent-websocket with eventlet, python-socketio and python-engineio, gaining support for Python 3 and the latest versions of the Socket.IO Javascript client. --- example/app.py | 16 +- example/requirements.txt | 18 +- example/templates/index.html | 10 +- flask_socketio/__init__.py | 377 ++++++++++++----------------------- setup.py | 5 +- 5 files changed, 154 insertions(+), 272 deletions(-) mode change 100644 => 100755 example/app.py mode change 100644 => 100755 example/requirements.txt mode change 100644 => 100755 example/templates/index.html mode change 100644 => 100755 flask_socketio/__init__.py mode change 100644 => 100755 setup.py diff --git a/example/app.py b/example/app.py old mode 100644 new mode 100755 index f20380ba..341f6157 --- a/example/app.py +++ b/example/app.py @@ -1,16 +1,16 @@ -from gevent import monkey -monkey.patch_all() +import eventlet +eventlet.monkey_patch() import time from threading import Thread from flask import Flask, render_template, session, request -from flask.ext.socketio import SocketIO, emit, join_room, leave_room, \ - close_room, disconnect +from flask_socketio import SocketIO, emit, join_room, leave_room, \ + close_room, rooms, disconnect app = Flask(__name__) app.debug = True app.config['SECRET_KEY'] = 'secret!' -socketio = SocketIO(app) +socketio = SocketIO(app, logger=True) thread = None @@ -54,7 +54,7 @@ def join(message): join_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 emit('my response', - {'data': 'In rooms: ' + ', '.join(request.namespace.rooms), + {'data': 'In rooms: ' + ', '.join(rooms()), 'count': session['receive_count']}) @@ -63,7 +63,7 @@ def leave(message): leave_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 emit('my response', - {'data': 'In rooms: ' + ', '.join(request.namespace.rooms), + {'data': 'In rooms: ' + ', '.join(rooms()), 'count': session['receive_count']}) @@ -93,7 +93,7 @@ def disconnect_request(): @socketio.on('connect', namespace='/test') -def test_connect(): +def test_connect(env): emit('my response', {'data': 'Connected', 'count': 0}) diff --git a/example/requirements.txt b/example/requirements.txt old mode 100644 new mode 100755 index e3ff7ed7..73115e49 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1,11 +1,11 @@ +eventlet==0.17.4 Flask==0.10.1 Flask-SocketIO -Jinja2==2.7.2 -MarkupSafe==0.18 -Werkzeug==0.9.4 -gevent==1.0 -gevent-socketio==0.3.6 -gevent-websocket==0.9.2 -greenlet==0.4.2 -itsdangerous==0.23 -ujson==1.33 +greenlet==0.4.7 +itsdangerous==0.24 +Jinja2==2.7.3 +MarkupSafe==0.23 +python-engineio==0.3.1 +python-socketio==0.1.0 +six==1.9.0 +Werkzeug==0.10.4 \ No newline at end of file diff --git a/example/templates/index.html b/example/templates/index.html old mode 100644 new mode 100755 index ee6ec742..6751bc4f --- a/example/templates/index.html +++ b/example/templates/index.html @@ -3,7 +3,7 @@ Flask-SocketIO Test - +