Added emit with callback in serve_tests
This commit is contained in:
parent
1669e90177
commit
133bd6f309
2 changed files with 16 additions and 4 deletions
|
|
@ -1,5 +1,8 @@
|
|||
= Resolve pull requests
|
||||
= Resolve pull request #6
|
||||
Add unit test for handling server callback
|
||||
+ Add emit with callback in serve_tests
|
||||
Use json with ensure_ascii=False
|
||||
Resolve issues
|
||||
Investigate issue #8
|
||||
Examine forks
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ try:
|
|||
from socketio.namespace import BaseNamespace
|
||||
from socketio.server import SocketIOServer
|
||||
except ImportError:
|
||||
import sys
|
||||
from setuptools.command import easy_install
|
||||
easy_install.main(['-U', 'gevent-socketio'])
|
||||
print('\nPlease run the script again to launch the test server.')
|
||||
import sys; sys.exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class Namespace(BaseNamespace):
|
||||
|
|
@ -15,8 +16,13 @@ class Namespace(BaseNamespace):
|
|||
def on_aaa(self, *args):
|
||||
self.emit('aaa_response', *args)
|
||||
|
||||
def on_bbb(self, *args):
|
||||
def callback(*args):
|
||||
self.emit('callback_response', *args)
|
||||
self.emit('bbb_response', *args, callback=callback)
|
||||
|
||||
class Application(object):
|
||||
|
||||
class App(object):
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
socketio_manage(environ, {
|
||||
|
|
@ -29,5 +35,8 @@ class Application(object):
|
|||
if __name__ == '__main__':
|
||||
from socketIO_client.tests import PORT
|
||||
print 'Starting server at port %s' % PORT
|
||||
socketIOServer = SocketIOServer(('0.0.0.0', PORT), Application())
|
||||
socketIOServer.serve_forever()
|
||||
try:
|
||||
server = SocketIOServer(('0.0.0.0', PORT), App())
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue