diff --git a/gluon/contrib/websocket_messaging.py b/gluon/contrib/websocket_messaging.py index ddeb1d15..c7f5d03f 100644 --- a/gluon/contrib/websocket_messaging.py +++ b/gluon/contrib/websocket_messaging.py @@ -1,4 +1,6 @@ +# -*- coding: utf8 -*- #!/usr/bin/env python + """ This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro @@ -17,13 +19,13 @@ Attention: Requires Chrome or Safari. For IE of Firefox you need https://github. 3) from any web2py app you can post messages with from gluon.contrib.websocket_messaging import websocket_send - websocket_send('http://127.0.0.1:8888','Hello World','mykey','mygroup') + websocket_send('http://127.0.0.1:8888', 'Hello World', 'mykey', 'mygroup') 4) from any template you can receive them with @@ -49,11 +51,11 @@ Or if you want to send json messages and store evaluated json in a var called da Here is a complete sample web2py action: def index(): - form=LOAD('default','ajax_form',ajax=True) + form=LOAD('default', 'ajax_form', ajax=True) script=SCRIPT(''' jQuery(document).ready(function(){ var callback=function(e){alert(e.data)}; - if(!$.web2py.web2py_websocket('ws://127.0.0.1:8888/realtime/mygroup',callback)) + if(!$.web2py.web2py_websocket('ws://127.0.0.1:8888/realtime/mygroup', callback)) alert("html5 websocket not supported by your browser, try Google Chrome"); }); @@ -65,7 +67,7 @@ Here is a complete sample web2py action: if form.accepts(request,session): from gluon.contrib.websocket_messaging import websocket_send websocket_send( - 'http://127.0.0.1:8888',form.vars.message,'mykey','mygroup') + 'http://127.0.0.1:8888', form.vars.message, 'mykey', 'mygroup') return form Acknowledgements: