i have legacy express project 2 servers. have 2 client files:
requirejs.config({ baseurl: '/js' , paths: { "jquery": "lib/jquery/jquery-2.1.1.min", "socket.io" : "lib/socket/socket.io" } }); requirejs(['jquery', 'socket.io'], function ($, io) { console.log(io); var socket = io('http://localhost:3000'); [....] and this:
requirejs.config({ baseurl: '/js/lib' , paths: { "ace": "ace/lib/ace" , "bcsocket": "/channel/bcsocket" , "sharejs": "sharejs/share" , "sharejs_ace": "sharejs/ace" , "ace_java": "ace/mode/java" , "jquery": "jquery/jquery-2.1.1.min" , "socket.io": "socket/socket.io" } , shim: { "bcsocket": { exports: "bcsocket" } , "sharejs": { exports: "sharejs" , deps: ["bcsocket"] } , "sharejs_ace": { deps: ["ace/ace", "sharejs"] } , "ace_java": { deps: ['ace/ace'] } } }); requirejs(['ace/ace', 'sharejs', 'bcsocket', 'sharejs_ace','jquery', 'socket.io'], function(ace, sharejs) { var editor = ace.edit('editor'); editor.settheme('ace/theme/twilight'); editor.getsession().setmode('ace/mode/java'); var socket = io('http://localhost:3000'); console.log(socket) socket.emit('hi'); [....] the thing is: can't access variable io second file, on first. , if manage join dependencies , files in one, socket.io stuff stops working.
this dependencies in someway conflicting , have no idea on to.
here's package.json:
"dependencies": { "express": "3.4.8", "jade": "*", "share": "^0.6.3", "socket.io": "^1.3.5", "connect": "*" }, thanks in advance
managed solve problem:
requirejs([‘ace/ace’, ‘sharejs’, ‘bcsocket’, ‘sharejs_ace’,’jquery’, ‘socket.io’], function(ace, sharejs, io) { and passing bcsocket variable io
so when changed to
requirejs([‘ace/ace’, ‘sharejs’, ‘socket.io’, ‘bcsocket’, ‘sharejs_ace’,’jquery’], function(ace, sharejs, io) { then passed socket.io variable io.
it problem order.
Comments
Post a Comment