passing properties on connection engine-io

300 views
Skip to first unread message

Michael Dausmann

unread,
Jul 14, 2015, 6:48:07 PM7/14/15
to sock...@googlegroups.com
I am using engine-io (1.5.2) on server and client.  my client connection looks like this.

<script src="lib/engine.io.js"></script>
...
socket = eio('ws://');

and my server side looks like this...

   var connect = require('connect');
   
var serveStatic = require('serve-static');
   
var app = connect().use(serveStatic(__dirname + '/client'));
   
var http = require('http').createServer(app).listen(9000);
   
var server = require('engine.io').attach(http);

   
.......

   server
.on('connection', (socket) => {
      console
.log('connection recieved from socket ' + socket.id + ' ' + JSON.stringify(socket.handshake))  
     
//... retrieve connection parameters?
   
});

How can I pass some information like user name etc to my server when a client connects?

I have seen some use of handshake and query but none of it is working and docs are a bit sparse.

Michael

Jonathan Chetwynd

unread,
Jul 15, 2015, 2:37:42 AM7/15/15
to sock...@googlegroups.com
Michael,

keep your project simple to start with: http://socket.io/docs/#

once you have that working...


there can be a problem with some firewalls, if perhaps you are at a college etc...


did you check that you have a public website, etc.


do you really need engine.io?


if so look at:
https://github.com/socketio/engine.io

best

Jonathan
Reply all
Reply to author
Forward
0 new messages