NPM

New: Parallel functionality - with an ability to send job and split it to sub workers More details below

The new parallel libary including those features:

More details below under the user instructions section

Usage instructions:

worker:

    yourWorkerName.start(function(socket){  
                            \\body   ....    });
    socket.on("messageName",callbackFunction(Data))
\\"testWorker.js" file
function Worker() {
  importScripts('../dist/WorkerIO.js');
  var testWorker = IO.Worker();
  testWorker.start(function(socket){
    socket.on("emitTest",function(data){
      console.log(data);

    })
    socket.emit("test","bla")
  })
  Worker();

caller:

 var io= IO.Reciver("testWorker.js");
  io.start(function(socket){
    socket.on("test",function(data){
      console.log("on: "+data);
      socket.emit("emitTest","bla");
    });
    socket.emit("emitTest","bla");
  });

parallel:

parallel.foreach([array of jobs...],function(socket,data){
      //communicating with a specific worker
      socket.emit("runParallel",data);
      socket.on("status",function(data){
        console.log("status: "+data);
      })
parallel.waitAny(function(workerName,data){
    //getting message when each  worker finish its job
    console.log("WaitAny: data was procced on: "+workerName+" with result "+data);
  }).waitAll(function(data){
    //getting message when all the job finsh their job
    console.log("WaitAll: data was procced with result "+data);
  })

full parallel example

caller:

  //imitJob
  var parallel= IO.Parallel("workerUnit.js");
  //Setting  Job and creating wrokers
  parallel.foreach([1,2,3,4,5,6,7,8],function(socket,data){
      //communicating with a specific worker
      socket.emit("runParallel",data);
      socket.on("status",function(data){
        console.log("status: "+data);
      })
  }).waitAny(function(workerName,data){
    //getting message when each  worker finish its job
    console.log("WaitAny: data was procced on: "+workerName+" with result "+data);
  }).waitAll(function(data){
    //getting message when all the job finsh their job
    console.log("WaitAll: data was procced with result "+data);
  });
  setTimeout(function(){
    //brodcasting message to the workers
    parallel.broadcast.emit("broadcasting",":)")
  }, 6000);

  function stopJob() {
    //removing all the jobs
    parallel.cancelAll();
  }

worker:

function parallelTest() {
  importScripts('../../dist/WorkerIO.js');
  var inter= null ;
  var testWorker = IO.Worker();
  testWorker.start(function(socket){
    socket.on("runParallel",function(data){
      console.log("runParallel: "+data);
      calc_data(data);
    }).on("broadcasting",function(data){
      console.log("broadcasting: "+data);
      });

    setInterval(function () {
      socket.emit("status","!!!Not finished yet")
    },5000);
    function calc_data(data) {
      inter =  setInterval(function(){
           var calcData = data*5
           socket.returnResult(calcData);
        }, data*1000);

    }
  })
}
parallelTest();