Socket.IO

Forwarding socket.io/engine.io connection to another server

给你一囗甜甜゛ 提交于 2019-12-25 09:01:56
问题 We are trying to find the best approach to our load balancing issue with websockets. Websocket can initially connect to any server, that server will run some logic and then if needed it will "redirect" the client to appropriate server. Is there a way in socket.io/engine.io to redirect/forward connections? Something like: io.use(function(socket){ // ... logic if(logic === true){ socket.redirect("172.10.10.2:3000"); } }); I am aware of that socket.redirect is not valid function but is there

How to send getusermedia recorded stream to server nodejs realtime

∥☆過路亽.° 提交于 2019-12-25 08:57:54
问题 I am able to send stream blob using socket.io to node js server. But, it is blinking while updating the blob data in video player. I want it to run smooth. How I can send data without blinking of video player. Here is my server code var express = require("express"); var app = express(); var http = require("http").Server(app); var io = require("socket.io")(http); var fs = require("fs") app.use(express.static('public')) app.get("/", function(req, res){ res.sendFile(__dirname+ "/public/index

socketIO data undefined

 ̄綄美尐妖づ 提交于 2019-12-25 08:29:57
问题 I'm trying to send data from my client to my server side. I only get undefined . I would like the user to click the ledOn function to send 1 and also click the ledOff to send 0 to the server. server.js io.sockets.on('connection', function(socket){ socket.on('ON', function (data) { console.log(data); }); socket.on('OFF', function (data) { console.log(data); }); }); client.js function ledOn() { socket.emit ('ON'); document.getElementById("ON").value = "1" console.log("Led is ON "); } function

Detect client disconnect

天涯浪子 提交于 2019-12-25 08:12:04
问题 I have a very simple socket.io connection. My server does the following: io.sockets.on("connection", function (socket) { console.log("CONNECTED ON SERVER"); socket.emit("connected", "CONNECTED!"); }); Indeed, the client gets the "CONNECTED!" message. I need to be able to detect when a client disconnects and take some action. I've tried: io.sockets.on("disconnect", function (socket) { console.log("DISCONNECTED!"); }); ...but this does not log "DISCONNECTED!" on the server. However, CONNECTED

Set up jsfiddle with requirejs, socketio, backbone

╄→гoц情女王★ 提交于 2019-12-25 07:42:44
问题 I've spent more than half a day trying to set up a requirejs, socket.io, backbonejs fiddle so as to solve another SO question. Here is what I tried. You may checkout my fiddle I tried a couple ways without any luck. I've loaded the scripts in the head like this. <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.2/require.js"></script> <script> requirejs.config({ paths: { 'socket.io': ['https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.5.1/socket.io.js'], 'jquery': [

Socket.IO bare-bones no-method objects or fully-equipped class-based objects for client updates?

℡╲_俬逩灬. 提交于 2019-12-25 06:31:08
问题 Say I have an array of players in my Node app, each player being an object. Every tick, I send my array to my clients, with Socket.IO. I'm not sure, out of the two following methods, would be the most efficient way of doing this: For each player , I add a basic object to my array, such as {id:1,x:10,y:20,color:"#000000"} . Then I can send the whole array, raw, to my clients. Functions that I need are non-object specific and handle the parsed object. This options is used in this Agar.io clone.

Saving socket.io client on phonegap resume or disconnecting it on pause

◇◆丶佛笑我妖孽 提交于 2019-12-25 05:35:07
问题 I have a phonegap application which uses socket.io as means of communication. When application goes to pause the socket is kept alive in the background apparently, and on resume when the page loads it replaces the old socket with a new one, and creates a new socket. By each resume socket connections are one more. Is there a way to keep the old socket connection when application resumes? Or to disconnect it when the application pauses? I'm using phonegap-websocket. 回答1: I have a similar issue.

Node + SSL = SLOW

▼魔方 西西 提交于 2019-12-25 05:17:11
问题 I have set up a node.js-server for running a chat service used by our site. It works. However some customers are NOT able to connect (is done automatically via javascript). They never pop up in the list of connected users (in ie 7,8,9). My site is running on https (port 443) and therefore my node.js-server is also running on SSL (port 8443) (with the same certificate). I am using Node 0.6.20 (have tried numerous other versions). I have the following package-setup: { "name":"My Chat",

Socket.io: Connection closed before receiving a handshake response

为君一笑 提交于 2019-12-25 04:57:22
问题 I decided to make a chat on socket.io, so I just copied an example from http://psitsmike.com/2011/09/node-js-and-socket-io-chat-tutorial/. Server side: var app = require('express').createServer() var io = require('socket.io').listen(app); app.listen(8080); app.get('/', function(req, res) { res.sendfile(__dirname + '/index.html'); }); var usernames = {}; io.sockets.on('connection', function(socket) { socket.on('sendchat', function(data) { io.sockets.emit('updatechat', socket.username, data); }

socket.io connect to unix socket

一笑奈何 提交于 2019-12-25 04:47:13
问题 I want to connect to unix socket using socket.io-client, No success (mostly timeout, last sample - dns resolution error). var clientio = require('socket.io-client'); // i tried all variants here //client=clientio.connect('port.io/',{'force new connection': true}); //client=clientio.connect('unix://port.io/',{'force new connection': true}); //client=clientio.connect('http//unix:port.io/',{'force new connection': true}); client.on('connect',connect); Is there any way to connect socket.io client