You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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'
});
`
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.
The text was updated successfully, but these errors were encountered:
Hi,
I was playing with your wrapper and had some issues,
`
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){
});
server.on('connect', function( client ){
client.on('close', function() {
});
});
`
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'
});
`
regards , thanks for your code.
The text was updated successfully, but these errors were encountered: