Sha256: 74f84d6fa7b526e2510be10a6da255d9f110f4bdfffd99b4b5b9faa734024907

Contents?: true

Size: 1.32 KB

Versions: 22

Compression:

Stored size: 1.32 KB

Contents

//Receive some messages
//Each message is in one flat array
//that has the following format
//[n_args, function_name, *args]
//Here is an example with one call
//  [1, 'print', 'hello world']
//Here is an example with two successive calls
//  [2, 'mul', 3, 4, 1, 'print', 'hello world']
function if_dispatch(qq) {
  //If debug socket is attached, forward events to it
  //and do not process the events
  <% if @mods.include? "debug" %>
    if (debug_socket && debug_socket_if_forward) {
      debug_socket.emit("if_dispatch", qq);
    } else {
  <% end %>

  //Get a priority queue
  while (qq.length > 0) {
    var q = qq.shift();

    //The very first thing is the queue type
    var queueType = q.shift();

    //Where there is still things left on the queue
    while (q.length > 0) {
      //Grab the first thing off the queue, this is the arg count
      var argc = q.shift();

      //Grab the next thing and look that up in the function table. Pass args left
      this[q.shift()].apply(null, q.splice(0, argc));
    }
  }

  //Continuation of the debug_socket at linke 10
  <% if @mods.include? "debug" %>
    }
  <% end %>
}

function ping() {
  int_dispatch([0, "pong"])
}

function ping1(arg1) {
  int_dispatch([1, "pong1", arg1])
}

function ping2(arg1, arg2) {
  int_dispatch([1, "pong2", arg1])
  int_dispatch([2, "pong2", arg1, arg2])
}

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
flok-0.0.38 app/drivers/chrome/src/dispatch.js
flok-0.0.36 app/drivers/chrome/src/dispatch.js
flok-0.0.35 app/drivers/chrome/src/dispatch.js
flok-0.0.34 app/drivers/chrome/src/dispatch.js
flok-0.0.33 app/drivers/chrome/src/dispatch.js
flok-0.0.32 app/drivers/chrome/src/dispatch.js
flok-0.0.31 app/drivers/chrome/src/dispatch.js
flok-0.0.30 app/drivers/chrome/src/dispatch.js
flok-0.0.29 app/drivers/chrome/src/dispatch.js
flok-0.0.28 app/drivers/chrome/src/dispatch.js
flok-0.0.27 app/drivers/chrome/src/dispatch.js
flok-0.0.26 app/drivers/chrome/src/dispatch.js
flok-0.0.25 app/drivers/chrome/src/dispatch.js
flok-0.0.24 app/drivers/chrome/src/dispatch.js
flok-0.0.23 app/drivers/chrome/src/dispatch.js
flok-0.0.21 app/drivers/chrome/src/dispatch.js
flok-0.0.20 app/drivers/chrome/src/dispatch.js
flok-0.0.19 app/drivers/chrome/src/dispatch.js
flok-0.0.18 app/drivers/chrome/src/dispatch.js
flok-0.0.17 app/drivers/chrome/src/dispatch.js