Socket.io connection url?
As of Socket.io version 1, resource has been replaced by path. Use : var socket = io(‘http://localhost’, {path: ‘/nodejs/socket.io’}); See: http://blog.seafuj.com/migrating-to-socketio-1-0
As of Socket.io version 1, resource has been replaced by path. Use : var socket = io(‘http://localhost’, {path: ‘/nodejs/socket.io’}); See: http://blog.seafuj.com/migrating-to-socketio-1-0
Archie1986’s answer was good but has become outdated with socketio updates (more specifically, its protocol : https://github.com/LearnBoost/socket.io-spec)… as far as i can tell, you need to perform the handshake manually before you can ask for a transport (e.g., websockets) connection… note that the code below is incomplete and insecure… for one, it ignores the list … Read more
Have you tried loading the socket.io script not from a relative URL? You’re using: <script src=”https://stackoverflow.com/questions/9945693/socket.io/socket.io.js”></script> And: socket.connect(‘http://127.0.0.1:8080’); You should try: <script src=”http://localhost:8080/socket.io/socket.io.js”></script> And: socket.connect(‘http://localhost:8080’); Switch localhost:8080 with whatever fits your current setup. Also, depending on your setup, you may have some issues communicating to the server when loading the client page from a different … Read more
As author, I suggest to try my SocketIO server implementation on Java: https://github.com/mrniko/netty-socketio Stable and production ready lib.
In a running server, the nginx’s configuration being used here is: # Requests for socket.io are passed on to Node on port 3000 location ~* \.io { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy false; proxy_pass http://localhost:3000; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection “upgrade”; }
Remove the socket listeners whenever the controller is destroyed. You will need to bind the $destroy event like this: function MyCtrl($scope, socket) { socket.on(‘message’, function(data) { … }); $scope.$on(‘$destroy’, function (event) { socket.removeAllListeners(); // or something like // socket.removeListener(this); }); }; For more information check the angularjs documentation.
Have a look at my primer on exactly this topic. UPDATE: var sio = require(‘socket.io’), app = require(‘express’).createServer(); app.listen(8080); sio = sio.listen(app); sio.on(‘connection’, function (client) { console.log(‘client connected’); // send the clients id to the client itself. client.send(client.id); client.on(‘disconnect’, function () { console.log(‘client disconnected’); }); });
This is all pretty straightforward with the socket.io rooms feature. Take a look at the documentation on LearnBoost wiki. https://github.com/LearnBoost/socket.io/wiki/Rooms It allows for being connected to multiple rooms over a single socket. I put together a quick test with the following code. Server io.sockets.on(‘connection’, function(client){ client.on(‘subscribe’, function(room) { console.log(‘joining room’, room); client.join(room); }) client.on(‘unsubscribe’, function(room) … Read more
It’s perfectly legal. Those callbacks are called ‘acknowledgement functions’ and are summarily mentioned in the Wiki and described a bit more in detail on the NPM page (‘Getting acknowledgements‘). EDIT: more recent documentation can be found here.
There’s two sides to WebRTC. JavaScript APIs (getUserMedia) that allow an app to access camera and microphone hardware. You can use this access to simply display the stream locally (perhaps applying effects), or send the stream over the network. You could send the data to your server, or you could use… PeerConnection, an API that … Read more