Socket.IO

Python heroku configure procfile gunicorn + gevent for socket.io chat app | RuntimeError: You need to use the gevent-websocket server

限于喜欢 提交于 2019-12-25 01:09:31
问题 I have a working chat app on localhost, but it does not work on heroku (Question from yesterday). After some research I think the problem is how I start the app. Procfile currently: web: gunicorn adult_main:app I need to use gevent in combination with gunicorn . This way I should be able to have max. 1000 socket.io connections, which is enough for me for the moment. I already installed and added gevent to the requirements.txt . Here an extract of the file: Flask-SocketIO==2.9.6 gunicorn==19.7

Callbacks are not supported when broadcasting

匆匆过客 提交于 2019-12-25 00:58:18
问题 Here I am facing one issue with Callbacks in socket.io with nodejs io.sockets.to(usersocketid).emit('receivemsg', {'success':'1','data':message},function(deliverycb){ console.log('delivery call back'); console.log(deliverycb); }); Where i am facing error of Callbacks are not supported when broadcasting so anyone have solution of this. 回答1: Emit doesn't have any callback. Broadcast your data first and then log it into console. let broadcastData = {'success':'1','data':message}; io.sockets.to

Socket.IO and Complex JSON with Node.js, jQuery

≯℡__Kan透↙ 提交于 2019-12-25 00:52:37
问题 I'm having a ton of trouble with this. I'm trying to make it so that when I move a square-div, the position of that div is relayed to another page via Socket.IO, so that the div moves in realtime. Only problem is that I don't have a clue how to do this! The documentation over at http://socket.io only confused me. My jQuery code: $(document).ready(function() { $("#mydiv").draggable().mousemove(function(){ var coord = $(this).position(); $("#left").val(coord.left); $("#top").val(coord.top); });

Socket.io: Not able send message to particular socket using socket.id

痞子三分冷 提交于 2019-12-25 00:42:40
问题 I am storing the socket.id of each user when he login using redis redisClient.set(user._id + ':socket', socket.id) When any post for this user._id is created, i am trying emit an event to the socket of that particular user using the socket.id stored above var mySocket=redisClient.get(user._id + ':socket') socket.broadcast.to(mySocket).emit('my message', msg); The problem is that I am not able to emit to that particular socket using the above code.I am using socket.io version > 1.0. Can

Javascript while loop waits for increment instead of becoming an infinite loop

回眸只為那壹抹淺笑 提交于 2019-12-24 23:44:05
问题 Right now in my nodejs socket.io 'game' I would like to cycle through all users currently online*, each having their opportunity to be a leader and click a button that would sequentially make the next user the leader (to, again, click a button that makes the next user the leader. You get the idea). My issue is that when I make the while loop wait for the 'leader' socket to trigger the leaderSelection event to increment the while loop, the while loop instead creates an infinite loop, crashing

How to disconnect a socket after streaming data?

佐手、 提交于 2019-12-24 22:45:55
问题 I am making use of "socket.io-client" and "socket.io stream" to make a request and then stream some data. I have the following code that handles this logic Client Server Logic router.get('/writeData', function(req, res) { var io = req.app.get('socketio'); var nameNodeSocket = io.connect(NAMENODE_ADDRESS, { reconnect: true }); var nameNodeData = {}; async.waterfall([ checkForDataNodes, readFileFromS3 ], function(err, result) { if (err !== null) { res.json(err); }else{ res.json("Finished

node process can not find setTimeout object in subsequent requests

余生颓废 提交于 2019-12-24 19:39:14
问题 I am trying to clear timeout set using setTimeout method by node process, in subsequent requests (using express). So, basically, I set timeout when our live stream event starts (get notified by webhook) and aim to stop this for guest users after one hour. One hour is being calculated via setTimeout, which works fine so far. However, if event gets stopped before one hour, I need to clear the timeout. I am trying to use clearTimeOut but it just can't find same variable. // Event starts var

Accessing a function stored in an object on server-side from client-side

无人久伴 提交于 2019-12-24 19:26:03
问题 Server-side: //When a player connects, all the players will get this message. game.sockets.emit('entrance', { id: socket.id, players: [], message: 'Player ' + socket.id + ' is online', store: function(id, object){ this.players.push({id: id, object: object}); } }); Client-side: socket.on('entrance', function(data){ console.log(data.message); data.store(data.id, new Car('hero').init()); }); This gives me the following error: It console.log 's the message stored in the object without a problem,

Setting up multiple socket.io/node.js apps on an Apache server?

半世苍凉 提交于 2019-12-24 19:16:09
问题 I've been messing around with socket.io and node.js recently and after successfully making a chat based application, I wanted to make another similar web app. I completed it and everything was working fine when I was hosting locally on my computer, but once I put it on my web server it stopped working. Node was serving the page just fine, but the socket.io connection was not being made. This is because of how I configured my Apache proxy settings to get the previous app working. Some

JS change socket namespace from client when click on button

孤者浪人 提交于 2019-12-24 19:00:25
问题 I'm developping simple app with nodejs and socket.io. I created two channels and I want my client connect one of channels when click on button. The problem is I don't get response from server This is my code : // SERVER side var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); var nameSpaceWeek = io.of('/week'); var nameSpaceDay = io.of('/day'); app.get('/', function(req, res){ res.sendfile('MDC.html'); }); io.on('connection', function