// Generated by IcedCoffeeScript 1.7.1-c
(function() {
  var Client, iced, __iced_k, __iced_k_noop;

  iced = require('iced-runtime').iced;
  __iced_k = __iced_k_noop = function() {};

  iced = require('./iced').runtime;

  exports.Client = Client = (function() {
    function Client(transport, program) {
      this.transport = transport;
      this.program = program != null ? program : null;
    }

    Client.prototype.invoke = function(method, args, cb) {
      var arg, err, res, ___iced_passed_deferral, __iced_deferrals, __iced_k;
      __iced_k = __iced_k_noop;
      ___iced_passed_deferral = iced.findDeferral(arguments);
      arg = {
        program: this.program,
        method: method,
        args: args,
        notify: false
      };
      (function(_this) {
        return (function(__iced_k) {
          __iced_deferrals = new iced.Deferrals(__iced_k, {
            parent: ___iced_passed_deferral,
            filename: "/Users/max/src/iced/node-framed-msgpack-rpc/src/client.iced",
            funcname: "Client.invoke"
          });
          _this.transport.invoke(arg, __iced_deferrals.defer({
            assign_fn: (function() {
              return function() {
                err = arguments[0];
                return res = arguments[1];
              };
            })(),
            lineno: 15
          }));
          __iced_deferrals._fulfill();
        });
      })(this)((function(_this) {
        return function() {
          return cb(err, res);
        };
      })(this));
    };

    Client.prototype.notify = function(method, args) {
      var program;
      method = this.make_method(method);
      program = this._program;
      return this.transport.invoke({
        program: this.program,
        method: method,
        args: args,
        notify: true
      });
    };

    return Client;

  })();

}).call(this);
