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

fix xmlhttprequest path #361

Closed
wants to merge 1 commit into from
Closed

fix xmlhttprequest path #361

wants to merge 1 commit into from

Conversation

goldsky
Copy link

@goldsky goldsky commented Dec 13, 2014

No description provided.

@inetfuture
Copy link

Looks like lib/xmlhttprequest.js never being used, am I missing something?

@nkzawa
Copy link
Contributor

nkzawa commented Dec 26, 2014

@inetfuture it's used for the browser build.
@goldsky could you explain the point of this PR?

@inetfuture
Copy link

Ok, found the config in package.json

"browser": {
    "xmlhttprequest": "./lib/xmlhttprequest.js"
  },

@goldsky
Copy link
Author

goldsky commented Dec 26, 2014

Looks like I'm missing something here.
It didn't pick up the correct path when it's running.

It threw error:

D:\localhost\nodejs>node server.js

D:\localhost\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\lib\transports\polling.js:23
  var xhr = new XMLHttpRequest({ xdomain: false });
            ^
TypeError: object is not a function
    at D:\localhost\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\lib\transports\polling.js:23:13
    at Object.<anonymous> (D:\localhost\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\lib\transports\polling.js:25:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (D:\localhost\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\lib\transports\polling-xhr.js:6:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

D:\localhost\nodejs>

And this is the server.js file:

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function (req, res) {
    res.sendFile(__dirname + '/server.html');
});

io.on('connection', function (socket) {
//    console.log('a user connected');
    io.emit('chat message', 'a user connected');
    socket.on('disconnect', function () {
//        console.log('user disconnected');
        io.emit('chat message', 'a user disconnected');
    });
});

io.on('connection', function(socket){
  socket.on('chat message', function(msg){
//    console.log('message: ' + msg);
    io.emit('chat message', msg);
  });
});

http.listen(1111, function () {
    console.log('listening on *:1111');
});

My fix solved it for me.
So, what was my problem?

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

Successfully merging this pull request may close these issues.

None yet

4 participants