node.js - Node JS: socket.io with multiple childs -


I am developing a server with a node JS, where I make more than one child with chrome Open an html

<("Chromium-Browser", ['RasmidiaVoicesOvim's']); Child.on ('exit', pre & gt; function () {res.writeHead (200, "0K", {'content-type': 'text / plain'}); res.end ();}); });

This HTML has a socket.io communication with the server:

  io.on ("connection", function (socket) {app.post ('/ Play video', function (rik, ridge) {socket.emit ("playvideo"); res.writeHead (200, "0K", {'content-type': 'text / plain'}); res. End ("content type ':' text / text '),' apopost '(' / pause video ', function (rick, ridge)) {socket.emit (" pausevideo "); res.writeHead (200," 0k "side '}); res.end ();});  

My problem is here if I create 2 childs_process with the code shown above I'm both chrome windows They are executed well but only taking socket.io events (works fine). Secondly, do not respond to any incident: S I have all children socket.io events? / Strong>

Here is a script for HTML handling events:

  var socket = io.connect ('http: // localhost: 3434'); On the socket (" PauseVideo ", function () {player.pause ();}); Socket.on (" playvideo ", function () {player.play ();});  

Thank you for your time.

You are calling the socket in those tasks which will only send to the calling socket. Instead try something like that.

  App post ('/ play video', function (rik, ridge) {io.sockets.emit ("playvideo"); res.writeHead (200, "0K", {'content -type: 'text / plain'}); res.end ();}); App.post ('/ pausevideo', function (req, res) {io.sockets.emit ("pausevideo"); res.writeHead (200, "0K", {'Content-type': 'text / plain'} ); Res.end ();}); Io.on ("connection", function (socket) {// handle event}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -