socket.io-1.0

latency issue with socket.io(websockets)

≡放荡痞女 提交于 2019-12-06 15:12:30
we are planning to create a real time SPA using node.js and we are testing for the latency, please go through the following link : http://173.200.239.98:6060/ there are 2 area...when user hover the mouse over a textarea in right side, we are printing the latency in the left side textarea and the latency is in milliseconds. the ques is that latency varies from 0.3 secs to 6 secs..is it normal with web sockets? or am i doing something wrong? NOTE:- the server is in detroit,usa and i am accessing the server from india chennai. SOURCE CODE: <!DOCTYPE html> <html> <head> <meta charset='utf-8'/> <

what does var io = require('../..')(server) do?

北慕城南 提交于 2019-12-05 12:20:49
I've build the project https://github.com/Automattic/socket.io/tree/master/examples/chat locally and it is working great. However, it would be nice to understand a little more about how a socket application works. In the main startup script one of the modules that is pulled in with require is var io = require('../..')(server) what does require('../..') do? thanks! When a path to a directory is given to require , it will implicitly look for an index.js in that directory. In this case, it's the equivalent of var socket = require("../../index.js"); var io = socket(server); In the example provided

Socket.IO: How do I remove a namespace

淺唱寂寞╮ 提交于 2019-12-05 05:49:08
I need to be able to construct and destruct socket.io namespaces on-the-fly. It is easily to find information how to create a namespace, but I find nothing about how I remove/disconnect the namespace to release its memory. Say I got the following code already running: var nsp = io.of('/my-namespace'); nsp.on('connection', function(socket){ console.log('someone connected'): }); nsp.emit('hi', 'everyone!'); How do I disconnect/remove the socket.io namespace created above? The io.of method just creates an array element: Server.prototype.of = function(name, fn){ if (String(name)[0] !== '/') name =

Can I stream microphone audio from client to client using nodejs?

偶尔善良 提交于 2019-12-04 20:55:01
问题 I'm trying to create a realtime voice chat. once a client is holding a button and talks, I want the sound to be sent over the socket to the nodejs backend, then I want to stream this data to another client. here is the sender client code: socket.on('connect', function() { var session = { audio: true, video: false }; navigator.getUserMedia(session, function(stream){ var audioInput = context.createMediaStreamSource(stream); var bufferSize = 2048; recorder = context.createScriptProcessor

Connect to socket.io(nodejs) via PHP

核能气质少年 提交于 2019-12-04 12:17:41
问题 I had a need to connect to websocket via php, send data and immediately disconnect. No need to wait for a response from the socket. I used elefant.io but after updating the library does not work. Please tell me how to connect to websocket via PHP? 回答1: I also encountered this problem. Learned a lot of structure websocket requests. I wrote a library for yourself, you can use it.PHP SocketIO Client. You need simple socket connect to nodejs, compose in this message format. 42["message", "your

Can I stream microphone audio from client to client using nodejs?

三世轮回 提交于 2019-12-03 13:20:18
I'm trying to create a realtime voice chat. once a client is holding a button and talks, I want the sound to be sent over the socket to the nodejs backend, then I want to stream this data to another client. here is the sender client code: socket.on('connect', function() { var session = { audio: true, video: false }; navigator.getUserMedia(session, function(stream){ var audioInput = context.createMediaStreamSource(stream); var bufferSize = 2048; recorder = context.createScriptProcessor(bufferSize, 1, 1); recorder.onaudioprocess = onAudio; audioInput.connect(recorder); recorder.connect(context

How do I get socket.io running for a subdirectory

风格不统一 提交于 2019-12-03 11:36:22
问题 I've got a proxy running that only hits my node.js server for paths that being with /mysubdir How do I get socket.io configured for this situation? In my client code I tried: var socket = io.connect('http://www.example.com/mysubdir'); but then I notice that the underlying socket.io (or engine.io) http requests are hitting http://www.example.com/socket.io/?EIO=3&transport=polling&t=1410972713498-72` I want them to hit http://www.example.com/mysubdir/socket.io..... Is there something I have to

Connect to socket.io(nodejs) via PHP

不羁的心 提交于 2019-12-03 07:48:58
I had a need to connect to websocket via php, send data and immediately disconnect. No need to wait for a response from the socket. I used elefant.io but after updating the library does not work. Please tell me how to connect to websocket via PHP? I also encountered this problem. Learned a lot of structure websocket requests. I wrote a library for yourself, you can use it. PHP SocketIO Client . You need simple socket connect to nodejs, compose in this message format. 42["message", "your message"] ' To encode to hybi10 (or hybi13) and send to websocket deibu var socket = require( 'socket.io' );

socket.io client connect disconnect

≯℡__Kan透↙ 提交于 2019-12-02 19:12:21
I am unable to figure out why disconnecting / connecting a socket.io connection multiple times is not working ? Server side code: io.on('connection', function(socket){ console.log('a user connected'); socket.on('disconnect', function(){ console.log('user disconnected'); }); }); Client side code: var socket = io(); socket.on('connect', function() { console.log("connected from the client side"); }); $('#connect_button').click(function(){ socket.connect(); }); $('#disconnect_button').click(function(){ socket.disconnect(); }); It disconnects alright. But doesn't reconnect. I'm using Socket.io 1.0.

Socket.IO 1.0.x: Get socket by id

妖精的绣舞 提交于 2019-12-01 15:05:58
In the 0.9.x version, we can get socket by ID like this: io.sockets.socket(socketId) But in 1.0.x we can't. How to find a socket by id in 1.0.x? For socket.io 1.0 use: io.sockets.connected[socketId] For 0.9 its io.sockets.sockets[socketId] and not io.sockets.socket[socketId] himanshu yadav you can also use like: io.to(socketid).emit(); Socket.io Version 2.0.3+ let namespace = null; let ns = _io.of(namespace || "/"); let socket = ns.connected[socketId] // assuming you have id of the socket 来源: https://stackoverflow.com/questions/27055989/socket-io-1-0-x-get-socket-by-id