From 4db37981e21f83c13f5ee4455cadcf392febcbc0 Mon Sep 17 00:00:00 2001 From: BuhtigithuB Date: Mon, 26 May 2014 10:57:47 -0400 Subject: [PATCH] coding utf8 and improve comment --- gluon/contrib/websocket_messaging.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gluon/contrib/websocket_messaging.py b/gluon/contrib/websocket_messaging.py index bf4630a2..17e6717b 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: