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 ?
>
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.