Thanks for the pull request Niphlod.
On Tuesday, December 10, 2013 9:09:29 PM UTC+1, Niphlod wrote: > > sent the PR https://github.com/web2py/web2py/pull/325 > Thanks for the patch. > > On Tuesday, December 10, 2013 5:57:37 PM UTC+1, Peter Govers wrote: >> >> Hello Lyn2py, >> >> I ran into the same problem as you did and couldn't quite figure out what >> caused it. The JS function 'web2py_websocket' is described in >> /static/js/web2py.js. The file web2py.js was given a makeover in Web2py >> 2.6.1 as changelog suggests: >> >> *For pre 2.6 applications to work with web2py >=2.6, you must copy >>> static/js/web2py.js, controllers/appadmin.py, and views/appadmin.html from >>> the welcome app to your own apps (all of them).* >> >> >> A quick look at the new web2py.js revealed that it features some >> additional code for compatibility reasons. But a wrong variable name has >> been used for web2py_websocket's compatibility code. Line 682: >> >> web2py_websocket = jQuery.web2py.websocket; >> >> Should be: >> >> web2py_websocket = jQuery.web2py.web2py_websocket; >> >> I have included a patch. >> >> On Friday, August 2, 2013 5:07:19 AM UTC+2, lyn2py wrote: >>> >>> I am trying the websocket on google chrome and encountered this error: >>> >>> Uncaught TypeError: Property 'web2py_websocket' of object [object >>> Object] is not a function >>> >>> I have followed the instructions. What could I be doing wrong? >>> >>> Thanks! >>> >>> On Friday, July 26, 2013 10:48:07 PM UTC+8, Massimo Di Pierro wrote: >>>> >>>> the basic idea of websocket is that input data must be validated by >>>> web2py therefore data can only be received from web2py. >>>> >>>> >>>> In your JS code you simply do: >>>> >>>> <script> >>>> >>>> $(document).ready(function(){ >>>> >>>> >>>> if(!web2py_websocket('ws://127.0.0.1:8888/realtime/mygroup',function(e){alert(e.data)})) >>>> >>>> >>>> alert("html5 websocket not supported by your browser, try >>>> Google Chrome"); >>>> }); >>>> >>>> </script> >>>> >>>> This makes the client join the group "mygroup" and is data is received, >>>> the callback function is called. >>>> You post by doing an ajax to web2py and web2py does >>>> >>>> from gluon.contrib.websocket_messaging import websocket_send >>>> >>>> websocket_send('http://127.0.0.1:8888','Hello World','mykey','mygroup') >>>> >>>> This sends the message "hello world" to all the members of the group >>>> "mygroup". >>>> >>>> Notice that web2py and websocket share a "mykey". This is how security >>>> is implemented. web2py validates input and it knows the key for posting. >>>> the only way to allow posting directly from JS would be to remove this >>>> security step or creating some authentication at the JS level. I do not >>>> trust authentication at the JS level. >>>> >>>> >>>> >>>> >>>> >>>> On Friday, 26 July 2013 09:08:37 UTC-5, Eduardo Cruz wrote: >>>>> >>>>> Is there a way to send data to a websocket from javascript >>>>> using web2py_websocket ? >>>> >>>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.