Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authenticated won't fired in server side.. #5

Open
Neumann-Valle opened this issue Dec 19, 2016 · 0 comments
Open

authenticated won't fired in server side.. #5

Neumann-Valle opened this issue Dec 19, 2016 · 0 comments

Comments

@Neumann-Valle
Copy link

Neumann-Valle commented Dec 19, 2016

Hi,

I was playing with your wrapper and had some issues,

  1. authenticated event don't fire in server side, see example
    `

var http = require('http');
var sockjs = require('sockjs');

// Require the wrapper
var server = new (require('sockjs-wrap'))();

// create sockjs server
var echo = sockjs.createServer();

// Create an http server
var http_server = http.createServer();

// Integrate SockJS and listen on /echo
echo.installHandlers( http_server, { prefix:'/sockets' } );

// Start server
http_server.listen(8080, '0.0.0.0');

// Attach the sockjs server to the wrapper
server.start( echo, { authentication: true } );

// Clients list
var clients = {};

server.on('authenticate', function(data, callback){

console.log(data);

callback( { result: true } );

});

// Connection fires authenticated event when successful
server.on('authenticated', function(user){

console.log(user);

});

server.on('connect', function( client ){

client.on('close', function() {

console.log('client disconnected with id ' + client.id);
delete clients[client.id];

});

});

`

Now in client I have

`
// connect to sockjs
var sock = new window.Connection();

// Open the connection
sock.on('connect', function(){
console.log('connected with the wrapper for sockJs');
sock.authenticate('1253615245');
});

sock.on('authenticated', function (data) {
// data will be the data given to the callback function on the server
// The user might have failed authentication here so be sure to check data for the result
console.log(data);
});

// If the SockJS client is in your HTML before you start
sock.start({
port : 80,
sockjs_path: '/sockets'
});

`

  1. Also I can't find the connection id, when if I listen to connect I get the client and I can have the id..

regards , thanks for your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant