Beispiel #1
0
mdp_client_t *
mdp_client_new (char *broker, int verbose, void* zmqctx)
{
    assert (broker);

    mdp_client_t *self = (mdp_client_t *) zmalloc (sizeof (mdp_client_t));
    self->ctx = zctx_shadow_zmq_ctx(zmqctx);
    self->broker = strdup (broker);
    self->verbose = verbose;
    self->timeout = 2500;           //  msecs

    s_mdp_client_connect_to_broker (self);
    return self;
}
Beispiel #2
0
void HHVM_METHOD(ZMQAuth, __construct, const Object& contextObj) {
  auto auth = Native::data<ZMQAuth>(this_);
  auto ctx = Native::data<ZMQContext>(contextObj);

  // NOTE (phuedx, 2014-05-14): A zauth object needs a context so that it
  // can take over authentication for all incoming connections in that
  // context. Creating a shadow context from the specified context allows
  // us to continue working with CZMQ.
  auth->shadow_context = zctx_shadow_zmq_ctx(ctx->context->z_ctx);
  if (!auth->shadow_context) {
    throwExceptionClass(s_ZMQAuthExceptionClass, "Failed to create the underlying shadow context object.", PHP_ZMQ_INTERNAL_ERROR);
  }

  auth->zauth = zauth_new(auth->shadow_context);
  if (!auth->zauth) {
    throwExceptionClass(s_ZMQAuthExceptionClass, "Failed to create the underlying zauth object.", PHP_ZMQ_INTERNAL_ERROR);
  }
}
Beispiel #3
0
zctx_t *
zctx_shadow (zctx_t *ctx)
{
    assert (ctx);
    // Initialize the original context now if necessary
    if (!ctx->context) {
        zctx__initialize_underlying (ctx);
        if (!ctx->context)
            return NULL;
    }
    zctx_t *self = zctx_shadow_zmq_ctx (ctx->context);
    if (self) {
        // copy high water marks and linger from old context
        self->pipehwm = ctx->pipehwm;
        self->sndhwm = ctx->sndhwm;
        self->rcvhwm = ctx->rcvhwm;
        self->linger = ctx->linger;
    }
    return self;
}