websocket: Send data when connect

19 views
Skip to first unread message

Manu Mora

unread,
Mar 5, 2015, 6:30:02 PM3/5/15
to web...@googlegroups.com
In websocket_messaging.py there are the following code:

class DistributeHandler(tornado.websocket.WebSocketHandler):
   
def open(self, params):
       
group, token, name = params.split('/') + [None, None]
       
self.group = group or 'default'
       
self.token = token or 'none'
       
self.name = name or 'anonymous'

I want to send some parameters like token or name. I have tried several options:

if(!web2py_websocket('ws://127.0.0.1:8888/realtime/chat?name=name',function(e){


if(!web2py_websocket('ws://127.0.0.1:8888/realtime/chat/name',function(e){

I would like to send some data to websocket server, however I don't work.

Massimo Di Pierro

unread,
Mar 5, 2015, 9:33:39 PM3/5/15
to web...@googlegroups.com
You are missing the point of the websocket system. You do not pass data when you connect it. You pass data using JS after you connect to it.

You can change this behavior (and I can see use cases when you have to) but you would have rewrite your own server side code.

Massimo
Reply all
Reply to author
Forward
0 new messages