diff --git a/VERSION b/VERSION index 8f1e5ff5..feadba47 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.9 (2012-09-24 15:54:52) stable +Version 2.0.9 (2012-09-24 16:21:05) stable diff --git a/applications/welcome/static/js/web2py.js b/applications/welcome/static/js/web2py.js index 0abe1907..61f45e30 100644 --- a/applications/welcome/static/js/web2py.js +++ b/applications/welcome/static/js/web2py.js @@ -155,7 +155,7 @@ function web2py_component(action, target, timeout, times){ web2py_ajax_page('get', action, null, target); } }); } -function web2py_comet(url,onmessage,onopen,onclose) { +function web2py_websocket(url,onmessage,onopen,onclose) { if ("WebSocket" in window) { var ws = new WebSocket(url); ws.onopen = onopen?onopen:(function(){}); diff --git a/gluon/contrib/comet_messaging.py b/gluon/contrib/websocket_messaging.py similarity index 86% rename from gluon/contrib/comet_messaging.py rename to gluon/contrib/websocket_messaging.py index c3f2ed35..890eb295 100644 --- a/gluon/contrib/comet_messaging.py +++ b/gluon/contrib/websocket_messaging.py @@ -12,18 +12,18 @@ Attention: Requires Chrome or Safari. For IE of Firefox you need https://github. 2) start this app: - python gluon/contrib/comet_messaging.py -k mykey -p 8888 + python gluon/contrib/websocket_messaging.py -k mykey -p 8888 3) from any web2py app you can post messages with - from gluon.contrib.comet_messaging import comet_send - comet_send('http://127.0.0.1:8888','Hello World','mykey','mygroup') + from gluon.contrib.websocket_messaging import websocket_send + websocket_send('http://127.0.0.1:8888','Hello World','mykey','mygroup') 4) from any template you can receive them with @@ -34,14 +34,14 @@ Or if you want to send json messages and store evaluated json in a var called da -- All communications between web2py and comet_messaging will be digitally signed with hmac. -- All validation is handled on the web2py side and there is no need to modify comet_messaging.py -- Multiple web2py instances can talk with one or more comet_messaging servers. -- "ws://127.0.0.1:8888/realtime/" must be contain the IP of the comet_messaging server. +- All communications between web2py and websocket_messaging will be digitally signed with hmac. +- All validation is handled on the web2py side and there is no need to modify websocket_messaging.py +- Multiple web2py instances can talk with one or more websocket_messaging servers. +- "ws://127.0.0.1:8888/realtime/" must be contain the IP of the websocket_messaging server. - Via group='mygroup' name you can support multiple groups of clients (think of many chat-rooms) Here is a complete sample web2py action: @@ -51,7 +51,7 @@ Here is a complete sample web2py action: script=SCRIPT(''' jQuery(document).ready(function(){ var callback=function(e){alert(e.data)}; - if(!web2py_comet('ws://127.0.0.1:8888/realtime/mygroup',callback)) + if(!web2py_websocket('ws://127.0.0.1:8888/realtime/mygroup',callback)) alert("html5 websocket not supported by your browser, try Google Chrome"); }); ''') @@ -60,8 +60,8 @@ Here is a complete sample web2py action: def ajax_form(): form=SQLFORM.factory(Field('message')) if form.accepts(request,session): - from gluon.contrib.comet_messaging import comet_send - comet_send('http://127.0.0.1:8888',form.vars.message,'mykey','mygroup') + from gluon.contrib.websocket_messaging import websocket_send + websocket_send('http://127.0.0.1:8888',form.vars.message,'mykey','mygroup') return form Acknowledgements: @@ -83,7 +83,7 @@ listeners = {} names = {} tokens = {} -def comet_send(url,message,hmac_key=None,group='default'): +def websocket_send(url,message,hmac_key=None,group='default'): sig = hmac_key and hmac.new(hmac_key,message).hexdigest() or '' params = urllib.urlencode({'message': message, 'signature': sig, 'group':group}) f = urllib.urlopen(url, params)