Ejemplo n.º 1
0
static int
s_agent_handle_data (agent_t *self)
{
    //  First frame is client address (hashkey)
    //  If caller sends unknown client address, we discard the message
    //  For testing, we'll abort in this case, since it cannot happen
    //  The assert disappears when we start to timeout clients...
    zmsg_t *request = zmsg_recv (self->data);
    char *hashkey = zmsg_popstr (request);
    client_t *client = (client_t *) zhash_lookup (self->clients, hashkey);
    free (hashkey);
    if (client) {
        //  Encrypt and send all frames of request
        //  Each frame is a full ZMQ message with identity frame
        while (zmsg_size (request)) {
            zframe_t *cleartext = zmsg_pop (request);
            if (zmsg_size (request))
                zframe_set_more (cleartext, 1);
            zframe_t *encrypted = curve_codec_encode (client->codec, &cleartext);
            if (encrypted) {
                zframe_send (&client->address, self->router, ZFRAME_MORE + ZFRAME_REUSE);
                zframe_send (&encrypted, self->router, 0);
            }
            else
                client_set_exception (client);
        }
    }
    zmsg_destroy (&request);
    return 0;
}
Ejemplo n.º 2
0
static int
s_agent_handle_data (agent_t *self)
{
    //  Encrypt and send all frames of request
    zmsg_t *request = zmsg_recv (self->data);
    while (zmsg_size (request)) {
        zframe_t *cleartext = zmsg_pop (request);
        if (zmsg_size (request))
            zframe_set_more (cleartext, 1);
        zframe_t *encrypted = curve_codec_encode (self->codec, &cleartext);
        if (encrypted)
            zframe_send (&encrypted, self->dealer, 0);
        else
            self->state = exception;
    }
    zmsg_destroy (&request);
    return 0;
}
Ejemplo n.º 3
0
///
//  Set frame MORE indicator (1 or 0). Note this is NOT used when sending
//  frame to socket, you have to specify flag explicitly.                
void QmlZframe::setMore (int more) {
    zframe_set_more (self, more);
};
Ejemplo n.º 4
0
JNIEXPORT void JNICALL
Java_org_zeromq_czmq_Zframe__1_1setMore (JNIEnv *env, jclass c, jlong self, jint more)
{
    zframe_set_more ((zframe_t *) (intptr_t) self, (int) more);
}