Socket.IO

Sailsjs Socket IO

雨燕双飞 提交于 2020-01-01 08:55:48
问题 I am new to SailsJs and Socket IO. I want to execute the below Socket IO example in Sailsjs. In the server side, I need to execute the following code. But I dont know where to place this code. var io = require('socket.io').listen(80); io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); }); I am aware that I can place this inside the Cntroller's function but it will add listener to every

Can't get Express session ID from cookies w/ Socket.IO

戏子无情 提交于 2020-01-01 08:01:30
问题 I have a typical web application in Node that is utilizing the Express framework and the session middleware. I am also using Socket.io for certain dynamic parts of my application (currently, this is a chat mechanism, but that's tangential). I've been able to successfully set up sessions and socket.io on their own, but would like to combine them (EG: to associate socket chat messages with user accounts without hitting the database). It should be noted (and I can see this being a possible issue

Sending data from flash to node.js server with socket.io

眉间皱痕 提交于 2020-01-01 05:51:31
问题 I have a simple socket.io based server in node.js that listens to a socket in port 81 (for example) I have no problem connecting and passing data between clients written in Javascript But after a lot of tries I can't get my Flash app to connect to the server and pass data to it (I found some examples in the web - but all of them are flex based and use classes that aren't parts of the basic AS3 libraries) when I'm trying to connect to the socket using a XMLSocket - I get Security Sandbox

How to use socket.io with the latest mean.io?

这一生的挚爱 提交于 2020-01-01 05:18:08
问题 I have fetched a copy of the latest Mean.io and noted quite a number of changes compared to the previous version I have been working with before. Now, what I am doing is creating a very basic chat application that uses socket.io with rooms. Following the basic setup in the Socket documentation I have to implement the following: var app = require('express')() , server = require('http').createServer(app) , io = require('socket.io').listen(server); server.listen(80); app.get('/', function (req,

IE and Socket.io compatibility

↘锁芯ラ 提交于 2020-01-01 05:16:48
问题 I make some chat example like here: http://psitsmike.com/2011/09/node-js-and-socket-io-chat-tutorial/ When I use Chrome and Firefox everything works like a charm. With IE9 or Opera some socket.io events are not firing (e.g. disconnect) or firing too late, and data receiving is too slow. I installed node.js and socket.io module with the npm method. Please help. 回答1: Socket.IO works best with websockets. Prior to 2012, most browsers did not support websockets (source). With such browsers,

Socket.IO error 'listen()' method expects an 'http.Server' instance after moving to Express 3.0

梦想的初衷 提交于 2020-01-01 04:03:47
问题 I began learning Node.js today and I'm a little stuck. Following this example, I get the following error when I try executing the js file: Warning: express.createServer() is deprecated, express applications no longer inherit from http.Server, please use: var express = require("express"); var app = express(); Socket.IO's `listen()` method expects an `http.Server` instance as its first parameter. Are you migrating from Express 2.x to 3.x? If so, check out the "Socket.IO compatibility" section

Socket.IO error 'listen()' method expects an 'http.Server' instance after moving to Express 3.0

£可爱£侵袭症+ 提交于 2020-01-01 04:03:28
问题 I began learning Node.js today and I'm a little stuck. Following this example, I get the following error when I try executing the js file: Warning: express.createServer() is deprecated, express applications no longer inherit from http.Server, please use: var express = require("express"); var app = express(); Socket.IO's `listen()` method expects an `http.Server` instance as its first parameter. Are you migrating from Express 2.x to 3.x? If so, check out the "Socket.IO compatibility" section

Angular 2 Updating objects in “real time.”

若如初见. 提交于 2020-01-01 03:33:05
问题 Hi I’m trying to wrap on how to update a table angular 2. Here is what I have: Backend: express / MongoDB. Updates are feed into the DB via an external app Data: 90% data will will be static. 10% of the data updates every second. I’ve looked at Observables / promises. HTTP requests/ socket IO but can’t wrap my mind around the concepts. Main Question: can I use observables with socket.io to update records? Other Questions about data updates Angular 2’s Observables – are observables use only

How to reconnect after you called .disconnect()

帅比萌擦擦* 提交于 2020-01-01 03:31:30
问题 Question: How do you reconnect a client to the server after you have issued a manual .disconnect() ? In my current project, I need to disconnect a client from the server when the user log out from the session. I did a socket.disconnect() to do the disconnection successfully. Server removed the user from the session. After awhile, the user decided to login again, but socket.io refuses to connect. I am clear that Socket.IO has implemented reconnection algorithm but clearly this is a different

How to create a handshake between PHP web server and Socket.io on node.js server?

♀尐吖头ヾ 提交于 2020-01-01 03:12:31
问题 I have a websocket running on node.js 4.0 on server 10.0.4.18 at port 8020. I implemented my websocket using socket.io v1.3, express, and express-session. Project Definition I need to be able to create a session in socket.io for every user that connects to it from a PHP application. After the user send the first HTTP request, I will authenticate them using a token that will be passed from PHP to socket.io along with the HTTP request. After the user is authenticated, I need to save some