node.js - Using Socket.IO in MeteorJS Server -
i trying top socket.io working meteorjs server. using package https://github.com/joncursi/socket-io-client, unable work server , cant figure out why.
i call "connecttoserver" method client, should contact remote server , initialise connection. when code executes, can see messages being logged, nothing inside "socket.on('connect',..." method. suggests isn't making connection. backed fact when run code client side (using the socket.io browser javascript code), able connect without issues.
i have code on server, whever there attempt connect socket.io connection. logged, client side code not server side code.
can see may doing wrong here?
meteor.methods({ 'connecttoserver': function() { socketiocontroller(); } }); function socketiocontroller(){ var username = 'asd'; var password = 'asd'; console.log("trying login asd"); var socket = io('https://localhost:3001/'); console.log("socket variable set"); socket.on('connect', meteor.bindenvironment(function() { console.log('connected websocket!'); //meteor.call('methodname1'); // on data event socket.on('data-event', meteor.bindenvironment(function(data) { console.log(data); meteor.call('methodname2'); }, function(e) { throw e; })); // on disconnect socket.on('disconnect', meteor.bindenvironment(function() { console.log('disconnected websocket!'); meteor.call('methodname3'); }, function(e) { throw e; })); }, function(e) { throw e; })); }
Comments
Post a Comment